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 lightsun47, Today, 03:51 PM
    0 responses
    2 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    8 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    41 views
    0 likes
    Last Post futtrader  
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    12 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    8 views
    0 likes
    Last Post port119
    by port119
     
    Working...
    X