Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add Orderflow Cumulative Delta

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

    #16
    Hello tonynt,

    Thanks for your reply.

    To clarify, your question is why is there a difference in the code generated by the strategy builder and the code shown in the help guide.

    The difference is that the strategy builder provides the complete overload coding. The difference between the two is that the strategy builder provides "Close" which is the data series to use. In the help guide (specifically the "Calling the OrderFlowCumulativeDelta() method by reference") "close" of the primary data series is assumed (and would be Close by default).


    Comment


      #17
      Hello,

      thank you for your reply. So as next step to check if the strategy works ok with the data from orderflow cum.delta I have added a simple code in the script.
      if(BarsInProgress==0)
      {
      if(OrderFlowCumulativeDelta1.DeltaClose[0] > OrderFlowCumulativeDelta1.DeltaOpen[0]) BackBrush = Brushes.LightGreen;
      if(OrderFlowCumulativeDelta1.DeltaClose[0] < OrderFlowCumulativeDelta1.DeltaOpen[0]) BackBrush = Brushes.MistyRose; }

      What might be the reason that backcolor is green when CD-Close[0]<CD-Open[0] but it should be mistyrose as you can see in the screenshot where the ellipse is. And the 2nd ellipse backcolor is mistyrose but should be lightgreen because CD close>open.

      And as I see now there are more backcolors of bars not ok from the code!

      Thank you!
      Tony
      Attached Files
      Last edited by tonynt; 10-29-2019, 02:54 PM.

      Comment


        #18
        Hello tonynt,

        Thanks for your post.

        With that code segment you posted, I would expect the background to be colored behind most of the bars yet the screenshot shows the first half of the chart is not colored at all so I suspect there is something else going on.

        I would suggest debugging your script by using print statements.

        Comment


          #19
          Hello Paul

          thank you for your reply. This is OK because at that time I started the strategy in the replay. However, I found it out in the meantime, as it is COBCtrue it plots the current bar and to have the bar with conditions colored I have to backplot 1 bar with brushes[1].

          Finally to resolve this question and finish this thread I have in what was told me in a strategy from stratbuilder. This code is only few lines and contains the CD and one condtion. I have added the 1 Tick Dataseries and 2 other dataseries to test. In the conditions I selected for the orderflow cumdelta for 5 Range Dataseries. From the code in strategy builder I can not see in the code where NT assigns the CD to that dataseries(?)

          Thank you!
          Tony
          Attached Files

          Comment


            #20
            Hello tonynt,

            Thanks for your reply.

            In the strategy builder it looks like you have indeed assigned the cumulative delta tot the 5 range bar.

            In the Ninjascript code, which I think is your question, is this line:

            OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(Closes[2], NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);

            The data series is assigned through "Closes[2]" meaning it is using the close price series of the 2nd added data series which is the 5 range bars. In a multi time frame/series script, you would use the "plurals" of price data to access the other added dataseries So Closes[0] would be the primary(Chart bar), Closes[1] would be the 3 range bar in your example. You are probably used to seeing something like Closes[2][0] which is the current close price of the 2nd added data series so the [2] points to the barsarray index of the added dataseries whilst the [0] points to the barsago. The input series to the indicator is Closes[2] which only needs to know the barsarray and that it why it appears as only Closes[2].

            Comment


              #21
              Hello Paul,

              thank you for your reply. This is what I was asking all the time.

              So, from this logic in the code do I understand right then when having OFcumDelta assigned to 2 dataseries (eg 1 minute and 5 Range)in State.DataLoaded then one can use it for entry-conditions outside a "if(BarsInProgress==..) {} bracket" (this is what I was missing in the stratbuilder-code when comparing with the samples from the above link for accessing OFcumDelta because in that link there is alwways an "if(BIP...)")
              by using it with eg
              if (OrderFlowCumulativeDelta1.DeltaClose[0] < OrderFlowCumulativeDelta1.DeltaLow[1]
              || OrderFlowCumulativeDelta2.DeltaClose[0] < OrderFlowCumulativeDelta2.DeltaLow[1])

              Thank you for your support and clearifying also this!
              Tony
              Last edited by tonynt; 10-30-2019, 10:14 AM. Reason: incorrect translation

              Comment


                #22
                Hello tonynt,

                Thanks for your reply.

                Yes, you can access the cumulative delta info from other data series in the strategy builder and use them as conditions for entry. The reason you can do this is that in the strategy builder you can only enter trades on the primary (chart) series and when you select the indicator and assign its data series as the other added dataseries it will pull that data in to be examined when the primary series runs OnBarUpdate(). If you look at the code generated by the strategy builder with multiple series you will see if (BarsInProgress != 0) return;

                Comment


                  #23
                  Hello,

                  when one wants to work with the High, Low and Open of cumDelta and not only with the Close does this mean there has to be

                  else if (State == State.DataLoaded)
                  {OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);
                  OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(Open, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);
                  OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(High, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);
                  OrderFlowCumulativeDelta1 = OrderFlowCumulativeDelta(Low, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);}

                  to access the High, Low and Open of OFcum.Delta for currentBar and the bars before?


                  Thank you!
                  Tony
                  Last edited by tonynt; 10-30-2019, 02:02 PM. Reason: translation error

                  Comment


                    #24
                    Hello tonynt,

                    Thanks for your reply.

                    If you are writing in a Ninjascript strategy no, you only need one and that will allow you to access the open, high, low and close.

                    Comment


                      #25
                      Hello,

                      when testing live and on replay there appears strange behavior. I have removed the added dataseries and run it only on the basic dataseries. It is a very simple code but it does not what it should.

                      In the attached screenshot one can see that the short entry at 8:48 was triggered with a bar where cumDelta was up, but from conditions the Close has to be lower than the Low of cdDelta before. (and also the downCD the bar before the Close was not lower than the Low of the bar before)

                      (and its also strange that entry is always on the 2nd bar which I have with "||" in the code)

                      Thank you!
                      Tony
                      Attached Files
                      Last edited by tonynt; 10-30-2019, 03:14 PM. Reason: typo

                      Comment


                        #26
                        Hello tonynt,

                        Thanks for your reply.

                        I do not see the code to update the cumulative delta indicator in your strategy which is required to keep in in sync.

                        Please see the help guide example here (2nd example): https://ninjatrader.com/support/help...ive_delta2.htm

                        Note that you will also need to:
                        1) remove the line: if (BarsInProgress != 0) return;
                        2)
                        bracket your existing code in if (BarsInProgress == 0) { your existing code }
                        3) Add the:
                        else if (BarsInProgress == 1)
                        {
                        // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                        OrderFlowCumulativeDelta1.Update(cumulativeDelta.B arsArray[1].Count - 1, 1);
                        }


                        Comment


                          #27
                          Hello Paul,

                          when doing a strategy with strategy builder cant I trust that there is everything in the script that should be? How does one know that there´s to add somehting else, and what has to be added. Or it would be a help if there would be a sample how to use this indicator in a script, like there are samples for many things.....

                          Can´t you update a sample with correct use of OFcumDelta? (with an entry or any use of the indicator to see what should be all in the script)

                          Thank you!
                          Tony

                          Comment


                            #28
                            Hello tonynt,

                            Thanks for your reply.

                            The strategy builder should provide all of the code to run correctly. The fact that it does not in the case of the OrderFlowCumulativeDelta indicator is an incorrect function of the strategy builder which I have reported to our QA team for review.

                            Until that has been corrected and publicly released, if you use the strategy builder to generate the code, you would need to unlock the strategy and modify as I've advised, directly in Ninjascript, otherwise the indicator data will be out of sync with the primary bars.

                            My post #26 shows what needs to be done to an unlocked script.

                            Alternatively, you can create your script directly in Ninjascript and follow the help guide to the same end.

                            Comment


                              #29
                              Hello,

                              a question please to your reply #10. With "The Volumetric bars also generate a lot more data/calculations and can optionally display all of that data so in that sense, the Volumetric bars would have a higher cpu/gpu expectation. If you are adding both indicators to your strategy, you only need to add a single 1 tick series as they both would use the same data (and any other indicator that needs a 1 tick series)." do you mean its more cpu when having a volumetric chart "..volumetric bars would have a higher cpu..." or also when running a script on a 1-min-chart and using the volumetric in the code or is it then the same for CPU as using orderflowcumulativedelta (because the volumetric bars are not plotted)

                              Thank you!
                              Tony

                              Comment


                                #30
                                Hello Tony,

                                Thanks for your reply.

                                GPU would be used if the Volumetric bars and data were display on a chart as this is the Graphics Procecessing Unit. If added as a data series in a script then only cpu would used. In both cases CPU is used.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                62 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                134 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X