Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cumulative Delta Strategy Logic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cumulative Delta Strategy Logic

    I am creating a strategy where one of the conditions to enter a trade is that the order flow cumulative delta is greater than a variable named "DeltaVolume"


    I am trying to follow the example in the help guide
    https://ninjatrader.com/support/help...tive_delta.htm

    There are two samples one for calling the method directly and one by reference, I am not sure what the difference is.

    I am getting error on compiling
    Operator > cannot be applied to operands of type ninjatrader.ninjascript.indicators

    I have attached some screenshots of the code and the strategy itself.

    Any help will be appreciated




    Attached Files

    #2
    Hello sdauteuil, thanks for writing in.

    Calling the OrderFlowCumulativeDelta by reference is better because you are not re-creating the cumulative delta object every time you call it. The problem with the code is you are not referencing which delta value series you want. The choices are: DeltaClose, DeltaOpen, DeltaHigh, and DeltaLow.

    Try printing out some values from the series e.g.

    Print(cumulativeDelta.DeltaClose[0]); // the most recent delta close update.

    Please let me know if you have any questions on this material.

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Not exactly sure where I need to add the DeltaClose or if I am using the right syntax

      I tried in the logic under onBarUpdate that is giving errors when compiling

      if ((Close[0] > SMA1[0])
      && (Close[0] > Close[1]))


      && (cumulativeDelta.DeltaClose[0] > DeltaVolume))

      *


      I also tried to add it in the variable definition which caused errors

      private OrderFlowCumulativeDelta.DeltaClose cumulativeDelta;

      *


      I tried to change the code under state.dataloaded - I get cannot convert to double error

      cumulativeDelta = OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0).DeltaClose[0];


      I am trying to learn how to program - still working on where and how to declare variables

      Thanks for the help


      Comment


        #4
        Hello sdauteuil, thanks for your reply.

        Remove DeltaClose[0] from cumulativeDelta = OrderFlowCumulativeDelta(BarsArray[0], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0).DeltaClose[0];

        This DataLoaded stage is used to initialize the cumulativeDelta object. The data access must take place in OnBarUpdate.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks for that

          In the previous post you said I needed to add DeltaClose somewhere in the code.
          Where would that be added?

          Calling the OrderFlowCumulativeDelta by reference is better because you are not re-creating the cumulative delta object every time you call it. The problem with the code is you are not referencing which delta value series you want. The choices are: DeltaClose, DeltaOpen, DeltaHigh, and DeltaLow.

          Comment


            #6
            Hello sdauteuil, thanks for your reply.

            Please follow the example from the help guide page on using this indicator. Consider starting with a test script that only includes this indicator so you can see the data it provides:

            https://ninjatrader.com/support/help...ive_delta2.htm
            "Calling the OrderFlowCumulativeDelta() method by reference"

            I have included a test indicator in this post, please see attached.

            If you have any further questions please let me know.
            Attached Files
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              That helped got the code working with no errors.

              When I run your indicator in the output window it matches the order flow indicator that comes with NT perfectly

              In the output window the strategy has the same time stamp as the indicator but the DeltaClose value matches the previous indicator value.
              (it is actually just slightly different from previous bar but close enough)

              Basically the strategy is behind by one bar.
              Attached Files

              Comment


                #8
                I did try to access the secondary series by adding [1] to the code but I am getting error "cannot apply expression[] to a double"

                cumulativeDelta.DeltaClose[1][0] > DeltaVolume

                Comment


                  #9
                  Apparently it is working properly

                  When I moved the print statement with entry execution the value in the output window matches the indicator.

                  Comment


                    #10
                    Hello sdauteuil,

                    If you need to have the most recent value from the Cumulative Delta indicator your script must run OnEachTick (Calculate == Calculate.OnEachTick). When it runs OnBarClose you will get the value of the last closed bar.

                    Please let me know if I can assist any further.
                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by michaelsh, Today, 04:28 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post michaelsh  
                    Started by Bmatarese, Today, 03:13 PM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by sdauteuil, Today, 12:32 PM
                    4 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Gaterz, 09-27-2020, 05:52 PM
                    10 responses
                    51 views
                    0 likes
                    Last Post tcea9
                    by tcea9
                     
                    Started by derivtrader, Today, 12:04 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Spencer  
                    Working...
                    X