Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderFlowCumulativeDelta int the multi instrument environment

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

    OrderFlowCumulativeDelta int the multi instrument environment

    How to apply the "OrderFlowCumulativeDelta" indicator to two different instruments inside one indicator?
    I do it by analogy with the Manual

    Code:
    private OrderFlowCumulativeDelta cumulativeDelta;
    private OrderFlowCumulativeDelta cumulativeDelta2;
    private CumulativeDeltaType deltaType=CumulativeDeltaType.BidAsk;
    
    ...
    else if (State == State.Configure)
    {
       AddDataSeries(Data.BarsPeriodType.Tick, 1);
    
       AddDataSeries("NQ 12-21",BarsPeriodType.Minute, 5);
       AddDataSeries("NQ 12-21",Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
       cumulativeDelta = OrderFlowCumulativeDelta(deltaType, CumulativeDeltaPeriod.Bar, 0);
       cumulativeDelta2 = OrderFlowCumulativeDelta(BarsArray[2],deltaType, CumulativeDeltaPeriod.Bar, 0);
    }
    ...
    
    protected override void OnBarUpdate()
    {
       if (BarsInProgress == 1)
       {
          cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
       }
       else if (BarsInProgress == 3)
       {
          cumulativeDelta2.Update(cumulativeDelta2.BarsArray[3].Count - 1, 1);
       }
    }

    Indicator 'DeltaTest': Error on calling 'OnBarUpdate' method on bar -1: Index was outside the bounds of the array.

    #2
    Hello jshapen,

    I was able to reproduce, and I suspect the added 1 tick series internally in the Order Flow Cumulative Delta may be the cause of the issue.

    I'll need to do some research and testing on this, I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello jshapen,

      The cumulativeDelta2.Update() call needs to reference the hosted indicators BarsArray collection and not the host strategy or indicators BarsArray collection.

      The indicator will have the primary BarsArray[0] which will be the 5 minute NQ, and the BarsArray[1] which is the NQ 1 tick series.
      Code:
      cumulativeDelta2.Update(cumulativeDelta2.BarsArray[B][1][/B].Count - 1, 1);
      Attached is an exported test script.
      Attached Files
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      566 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X