Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate Error

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

    OnBarUpdate Error

    I am getting the following error message in a multi-timeframe strategy:

    " **NT** Error on calling 'OnBarUpdate' method for strategy 'ZLReMTF/e610e684089b44a2b751f1e4043ed90d': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceExit() method in the context of a multi-time frame and instrument strategy."


    The code associated with BarsSinceExit is:


    if(BarsInProgress == 0)
    {
    TimeSinceExitOK = BarsSinceExit() >= 1 || BarsSinceExit() == -1;
    TimeSinceEntryOK = BarsSinceEntry() >= 1 || BarsSinceEntry() == -1;
    }


    Anyone have any ideas?


    Rod

    #2
    Hello,

    BarsSinceExit() has an overload for the barsInProgressIndex that needs to be specified in an multi series script.

    BarsSinceExit(int barsInProgressIndex, string signalName, int exitsAgo)

    For example,

    if(BarsSinceExit(1, "mySignal", exitago) == 1)

    Where 1 is the BIP
    MatthewNinjaTrader Product Management

    Comment


      #3
      I must be doing something wrong...

      I am getting the same error


      I have changed my code as follows
      TimeSinceExitOK = BarsSinceExit(1,"ZLRe1",0) >= 1 || BarsSinceExit(1,"ZLRe1",0) == -1;
      TimeSinceEntryOK = BarsSinceEntry(1,"ZLRe1",0) >= 1 || BarsSinceEntry(1,"ZLRe1",0) == -1;
      In your post, you used the barsInProgressIndex of 1. That is not the primary data, is it?

      Comment


        #4
        barsInProgressIndex of 1 would be the second data series.


        The primary series is 0. Do you continue to receive errors if you use 0 as the bIP Index?
        MatthewNinjaTrader Product Management

        Comment


          #5
          my mistake - I had changed to '0' but I had missed one instance of BarsSinceExit in the code

          problem solved

          thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          65 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X