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

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
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rbeckmann05, Yesterday, 06:48 PM
    1 response
    12 views
    0 likes
    Last Post bltdavid  
    Started by llanqui, Today, 03:53 AM
    0 responses
    6 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    15 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Working...
    X