Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cannot enable compiled strategy - **NT** Error on calling 'OnBarUpdate' method

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

    cannot enable compiled strategy - **NT** Error on calling 'OnBarUpdate' method

    Dear All,

    I developed a NT7-Strategy with parameters as follows:

    protected override void Initialize()
    {
    ...
    CalculateOnBarClose = true;
    Add(contract, PeriodType.Minute, 5);
    ...
    }

    protected override void OnBarUpdate()
    {

    if (Bars == null)
    return;

    if (BarsInProgress == 1)
    {
    ...
    }

    I compiled the strategy without any errors.
    I set up the strategy on a 5 minute ES-chart but I cannot enable it. An error message occurs at the output-window as follows:

    "**NT** Error on calling 'OnBarUpdate' method for strategy 'OHLCStrategy/794829efae334eb0b1e2223f4e2921ef': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

    Another strategy which a developed with the same code structure as described above works without any problem. This confuses me as the "main" definition and code is in both strategies equal. Is it possible that a small code snippet is responsible for this issue?

    Could you please advise what this message indicates or what to change at the code
    in order to get rid of the error message and to enable to set up the strategy?

    Many thanks.

    Cheers!

    Rob

    #2
    Hi Rob, thanks for the post - would you see the same outcome if a check for enough bars in both series would be added? Like shown here? http://www.ninjatrader.com/support/h...sub=CurrentBar

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    52 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X