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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X