Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CUMULATIVE DELTA in STRATEGY

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

    CUMULATIVE DELTA in STRATEGY

    I am trying to incorporate Order Flow Cumulative Delta ( for which I have full subscription) to a strategy through strategy builder.
    However for some reason strategy immediately disables itself after enabling. I tested it on a simplest of set-ups ( CUMDELTA > 0 Long, < 0 EXIT) on RANGE and TICK based charts and results is the same. I made sure about calculus on each tick in the strategy and SHOW TICK REPLAY in Market Data OPtions TOOLS. So I hypothesize that there is a bit of conceptual thing that makes CUMULTAIVE DElTA currently impossible to incorporate. Any explanations and suggestions how to fix it ? Cheers

    #2
    Hello kazbbek966,

    Thanks for your post.

    The Order Flow Cumulative Delta indicator cannot be used in the Strategy Builder strategy.

    To use the indicator in a custom NinjaScript strategy you must unlock the script from the Strategy Builder and manually program your strategy logic.

    This help guide page details how the Order Flow Cumulative Delta indicator is referenced in a custom NinjaScript. You could also view the sample code on this help guide page: https://ninjatrader.com/support/help...ive_delta2.htm

    If at any time you enable a strategy and it automatically disables, you should check the Log tab of the Control Center to see if any errors occurred and what the errors might be.

    Please let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon, on a similar topic. I mentioned that by default Cumulative Delta (CD) is calculated on a tick by tick. Though I also managed to plot it on Renko bars with CD values calculated on Bar Close. The question is whether it is theoretically possible to specify calculation of CD based on Renko bar closure in custom script created by NinjaEditor ? Cheers

      Comment


        #4
        Hello kazbek966,

        Thanks for your note.

        That is correct. The Order Flow+ Cumulative Delta indicator runs off tick data. You must add an additional 1-tick data series to the NinjaScript you are accessing the Order Flow+ Cumulative Delta indicator in so that the indicator can properly calculate data.

        This could be seen in the sample code in the Order Flow+ Cumulative Delta help guide page linked below.

        From the help guide:

        // A 1 tick data series must be added to the OnStateChange() as this indicator runs off of tick data
        else if (State == State.Configure)
        {
        AddDataSeries(Data.BarsPeriodType.Tick, 1);
        }


        Order Flow+ Cumulative Delta: https://ninjatrader.com/support/help...ive_delta2.htm

        Please let me know if you have further questions on this matter.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Indeed, Brandon, I have taken a look at the help guide and it is addition of ONE tick data confused me a bit as Single tick data is an awfully high resolution to begin with and I would hate not only to see in the chart, but also clatter calculation space. Nevermind. So did I understood correctly that addition of "virtual" single tick data series allows to overcome CD limitation and help to create strategy for Renko bars as well. Another question : to the best of my understanding I can specify calculation of RANGE bars based on TICKS, this would suppose to overcome CD tick based limitation. Nevertheless Strategy including OrderFlow CD implemented on RAnge bars also disables itself despite specific instruction of RAnge bar calculus based on Ticks. This confuses me a bit as well.

          Comment


            #6
            Hello kazbek966,

            Thanks for your notes.

            Since the Order Flow Cumulative Delta indicator requires tick data to process information, a 1-tick data series must be added to a script that references the Cumulative Delta indicator so the indicator can calculate values properly.

            If a custom indicator or strategy automatically disables after being enabled, there is likely an error occurring with the script.

            Do you see any error messages appear or are there any error messages in the Log tab of the Control Center? If so, what exactly do those errors report?

            I look forward to further assisting.

            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Hello Brandon,

              A bit of background. I am actually testing 3 CD indicators. One is from NT8 Order Flow Suite. Second is from NT ecosystem scripted by Gill and third is from trading-revealed.
              CD from Trading Revealed works just fine, while CD from OF and scripted by Gill are not functioning in current implementing by strategy builder.

              2022-12-29 06:41:41:024|3|4|'Cumulative Delta' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load MNQ 03-23 Globex: 1 Tick
              2022-12-29 06:41:41:143|3|4|'Order Flow Cumulative Delta' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load MNQ 03-23 Globex: 1 Tick
              2022-12-29 06:42:26:642|1|4|Enabling NinjaScript strategy 'MOMENTonCUMDELTAShort/282307664' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions, ignore order rejections ExitOnSessionClose=True / triggering 180 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Keep running DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=True CancelExitsOnStrategyDisable=True Calculate=On each tick IsUnmanaged=False MaxRestarts=4 in 5 minutes

              As you mentioned both of latter are trying to load additional 1 Tick data and obviously complaining and thats where I got confused as I am loading both of them on Range based chart with TICK options enabled everywhere where it is possible and impossible. So the real question is why those two CDeltas complaining about lack of tick data when being instructed to operate on TICK based chart with tick data already loaded and available.
              Thats where I am not clear about. By the way same situation exists with OF and Gill CD on TICK based charts themselves which actually raises same point but in a bit more elegant way as TICK based chart is consists of ... ticks that to the best of my understanding are already loaded, so what are those CumDeltas indicators are complaining about in the first place. My only educated quess that in order for CD to operate in a strategy it actually requires 1 tick data no matter what, though both of those CDs are functioning just fine in Renko , range, tick and all other charts by themselves so obviously enough data are available otherwise they would not be able to chart anything.

              2022-12-29 07:13:07:431|3|4|'Cumulative Delta' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load MNQ 03-23 Globex: 1 Tick
              2022-12-29 07:13:07:465|3|4|'Order Flow Cumulative Delta' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load MNQ 03-23 Globex: 1 Tick​

              I have taken a look at Gill CD script and to the best of my understanding it follows steps outlined in the NT8 help guide by adding 1 TICK series from the get go in state configure. So by using this indicator that instructs to load 1 tick data itself I somehow presume that conditions specified in help guide with regards to addition of 1TICK data are fulfilled by default. But I may be wrong here as I am making assumptions based on conventional logic which may not necessarily operate in scripting.


              Last edited by kazbek966; 12-29-2022, 08:13 AM.

              Comment


                #8
                Hello kazbek966,

                Thanks for your note.

                "while CD from OF and scripted by Gill are not functioning in current implementing by strategy builder."

                To clarify, the Order Flow Cumulative Delta indicator that comes default with NinjaScript is not accessible in a Strategy Builder strategy.

                Do you mean that you created a Strategy Builder strategy and then unlocked the script from the Strategy Builder to add Order Flow Cumulative Delta to your script?

                "'Cumulative Delta' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load MNQ 03-23 Globex: 1 Tick"

                Ultimately, the error is selling us a single tick data series was expected to be added to the script when using Order Flow Cumulative Delta. To resolve this error you must add a single tick data series to any of your scripts that are adding Order Flow Cumulative Delta. Secondary data series could be added to a script using the AddDataSeries() method.

                Example code that shows how this indicator can be hosted can be found below.

                https://ninjatrader.com/support/help...JASCRIPTaccess

                Please let me know if I may assist further.​
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  Hi Brandon,

                  Provided link referenced me back to earlier Of+Cd link so nothing particularly new could be gained by circling around.
                  Indeed I could not access OF CD directly from the Strategy Builder but could get an access to it by referencing it from another indicator. Not quite clear why this is the case, but that I was wondering about how come I dont see OF suit directly in Strategy Builder but can see through Momentum ( ), Slope and all other indicators. I understand that in order to use OF I need to do a bit of manual scripting taking into account this 1 TICK series addition.
                  Now if I want to simply create condition in the scripted strategy that OF CD > 1000 ( example) would strategy still function despite the fact that OF CD is not accessible in Strategy Builder ?
                  Are there any examples of the strategy including OF CD for educational purposes just to be on the safe side ?

                  Comment


                    #10
                    Hello kazbek966,

                    Thanks for your note.

                    The Order Flow Cumulative Delta indicator cannot be used in a Strategy Builder strategy because the indicator's code is too complex.

                    To successfully use the Order Flow Cumulative Delta indicator in a custom NinjaScript strategy, you need to unlock the script from the Strategy Builder and manually program the logic in your script similar to what is seen in the Order Flow Cumulative Delta help guide page.

                    The Order Flow Cumulative Delta indicator could be used for strategy conditions in an unlocked script, not in a Strategy Builder strategy.

                    Note that in the sample code of the Order Flow Cumulative Delta help guide page we use AddDataSeries() to add a 1-tick data series to the script for the indicator to use for calculations. This 1-tick secondary series must be added to any NinjaScript that adds the Order Flow Cumulative Delta indicator. We do not have a reference sample specifically using Order Flow Cumulative Delta in a strategy, however, you would access the indicator's values similar to the sample code seen on the Order Flow Cumulative Delta help guide page.

                    Momentum is an indicator separate from the Order Flow Cumulative Delta indicator.

                    Let me know if you have further questions on this.
                    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                    Comment


                      #11
                      Thanks Brandon,
                      Adding series is not a big deal as I can add it even through strategy builder itself.
                      I was a bit unsure how current conditions in any Script created by Strategy Builder

                      protected override void OnBarUpdate()
                      {
                      if (BarsInProgress != 0)
                      return;

                      if (CurrentBars[0] < 1)
                      return;

                      Would correspond to suggested in Help guide

                      if (BarsInProgress == 0)

                      {

                      // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period

                      Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);

                      }

                      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

                      cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

                      }

                      ​Other then that any Strategy condition will be preserved so that shud not be a problem.

                      Cheers

                      Comment


                        #12
                        Hello kazbek966,

                        Thanks for your note.

                        The if-else-if condition you shared would be used inside the OnBarUpdate() method.

                        First, you would remove the if (BarsInProgress != 0) condition from your script.

                        Then you could copy that code into your strategy's OnBarUpdate() method. The logic you want to happen on the primary series would be placed inside the if (BarsInProgress == 0) condition. For example, you could add your conditions and entry/exit order methods in this condition.

                        An example of the code might look something like this.
                        Code:
                        protected override void OnBarUpdate()
                        {
                            if (CurrentBars[0] < 1 && CurrentBars[1] < 1)
                                return;
                        
                            if (BarsInProgress == 0)
                            {
                                // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
                                Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);
                        
                                if (cumulativeDelta.DeltaClose[0] > 1000)
                                {
                                    EnterLong();
                                }
                            }
                            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
                                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                            }​
                        }

                        See the help guide documentation below for more information.
                        CurrentBars: https://ninjatrader.com/support/help...urrentbars.htm
                        BarsInProgress: https://ninjatrader.com/support/help...inprogress.htm

                        And, review this help guide page about programming a Multi-Timeframe or Multi-Instrument NinjaScript. It is important to understand this help guide page when developing these types of scripts.


                        Please let me know if I may assist further.
                        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        88 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        48 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        30 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        34 views
                        0 likes
                        Last Post TheRealMorford  
                        Started by Mindset, 02-28-2026, 06:16 AM
                        0 responses
                        68 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Working...
                        X