Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderFlowCumulativeDelta Issue

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

    OrderFlowCumulativeDelta Issue

    I am creating an indicator that is referencing the OrderFlowCumulativeDelta indicator and I'm having an issue accessing the correct values. I've attached a sample indicator that will show the issue. Why is my sample indicator plotting different values than the OrderFlowCumulativeDelta indicator?



    Click image for larger version

Name:	2023-07-30_13-35-43.png
Views:	135
Size:	44.9 KB
ID:	1262262

    #2
    Hello SystemTrading,

    Thanks for your post.

    I see in the screenshot you shared that the Order Flow Cumulative Delta indicator is set to use Bar for the Period property.

    In the code you shared, you are using CumulativeDeltaPeriod.Session, not CumulativeDeltaPeriod.Bar.

    cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Session, 0);

    You should change the 'Period' property of the Order Flow Cumulative Delta indicator to 'Bar' instead of 'Session' to compare your indicator to the Order Flow Cumulative Delta indicator.

    When comparing your custom indicator to the Order Flow Cumulative Delta indicator that comes with NinjaTrader, make sure that you are using the exact same settings in the Order Flow Cumulative Delta indicator as you are using in your custom script.

    <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
      Good catch. However, I am still having an issue beyond that. I've attached code for two indicators named TestA and TestB. The TestA indicator is referencing the OrderFlowCumulativeVolume indicator, and the TestB indicator is referencing the TestA indicator. Historically, the plots match as I would expect. However, they do not match in real-time.

      Click image for larger version

Name:	2023-07-31_09-50-14.png
Views:	132
Size:	38.1 KB
ID:	1262355

      I added some print statements to help determine what is happening. In the window below, the lines labeled "Chart Indicator" are being printed by the instance of the TestA indicator that is visible on the chart. The lines labeled "Signal Indicator" are being printed by the instance of the TestA indicator that is being referenced by indicator TestB (i.e. it is not visible on the chart). As you can see, the delta values being returned to the two instances are different. Why would this be?

      Click image for larger version

Name:	2023-07-31_09-53-38.png
Views:	117
Size:	35.0 KB
ID:	1262356

      Comment


        #4
        Hello SystemTrading,

        Thanks for your notes.

        When testing the indicator script you shared, TestA and TestB, on a 1-Minute ES 09-23 chart I am seeing that the indicator plots do match when running on real-time data.

        See this demonstration video showing that the TestA indicator plots and TestB indicator plots match up: https://brandonh-ninjatrader.tinytak...NV8yMTgzODExMQ

        I suggest opening a new blank chart and adding those indicators to the blank chart window to retest the indicator scripts you shared to see if the plots match.
        <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
          What about your output window? Did the values match? I've updated my example to better reflect the issue.
          Attached Files
          Last edited by SystemTrading; 07-31-2023, 09:23 AM.

          Comment


            #6
            Hello SystemTrading,

            Thanks for sharing that updated sample script.

            In the TestB indicator script, you would need to call .Update() on ind in BarsInProgress 1 to update the secondary series of the cached indicator to make sure the values you get in BarsInProgress == 0 are in sync. This is similar to how you are updating cumulativeDelta in the TestA indicator script.

            For example:
            Code:
            if (BarsInProgress == 1)
                     ind.Update(ind.BarsArray[1].Count-1, 1);
            else
                    Values[0][0] = ind.Values[0][0];​
            I have attached an exported sample demonstrating this and a screenshot showing the values match.
            Attached Files
            <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
              That works! Thank you so much for your assistance.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by giulyko00, Today, 05:30 AM
              0 responses
              4 views
              0 likes
              Last Post giulyko00  
              Started by globaljobber, Today, 05:26 AM
              0 responses
              3 views
              0 likes
              Last Post globaljobber  
              Started by totalnewbie, Today, 04:45 AM
              0 responses
              8 views
              0 likes
              Last Post totalnewbie  
              Started by Skifree, Today, 01:35 AM
              0 responses
              10 views
              0 likes
              Last Post Skifree
              by Skifree
               
              Started by somanko, Yesterday, 11:51 AM
              3 responses
              25 views
              0 likes
              Last Post somanko
              by somanko
               
              Working...
              X