Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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


    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:


            "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 PaulMohn, Today, 03:49 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post PaulMohn  
                    Started by inanazsocial, Today, 01:15 AM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Jason  
                    Started by rocketman7, Today, 02:12 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post rocketman7  
                    Started by dustydbayer, Today, 01:59 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post dustydbayer  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    5 responses
                    23 views
                    0 likes
                    Last Post trilliantrader  
                    Working...
                    X