Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 giulyko00, Today, 11:49 AM
      2 responses
      11 views
      0 likes
      Last Post giulyko00  
      Started by Aviram Y, Today, 06:03 AM
      2 responses
      10 views
      0 likes
      Last Post Aviram Y  
      Started by FishTrade, Today, 03:42 PM
      0 responses
      1 view
      0 likes
      Last Post FishTrade  
      Started by Richozzy38, Today, 01:06 PM
      3 responses
      14 views
      0 likes
      Last Post Richozzy38  
      Started by ttrader23, Today, 09:04 AM
      2 responses
      12 views
      0 likes
      Last Post ttrader23  
      Working...
      X