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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    666 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    376 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X