Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add("ZC 12-14", PeriodType.Minute, 30);

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

    Add("ZC 12-14", PeriodType.Minute, 30);

    Dear NinjaTrader,

    I am trying to run multiple futures in one strategy.

    I put the below in Initialize(), but the strategy does not run (not turn green), and no error message either. The strategy is set up for "ZW 12-14", 30m bar.

    Add(
    "ZS 01-15", PeriodType.Minute, 30);

    Is my name "ZS 01-15" used wrong?

    Thank you

    #2
    Your use of ZS 01-15 is valid, however when dealing with multi series scripts, you do need to ensure that all added data series have met their bars required before it will begin processing OnBarUpdate().

    The default bars required is 20.

    To ensure that you have met this, you need to first increase the number of "days to load" or "bars" that are processed in the strategy settings to ensure you have at least twenty 30-minute bars (in your case) or any other series added through code or on a chart.

    You will also need to add some checks at run time to skip over bars which do not yet meet the requirement at the beginning of OnBarUpdate

    Code:
    protected override void OnBarUpdate()
    {
    //if the current bar array of 0, or the current bar array of 1 is less than bars required, do nothing
    
    if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
    return;
    }
    CurrentBars[0] is the primary series on your chart, and CurrentBars[1] is the series you Add. You'd need to expand this if you ever wanted to add additional series.

    Please review the information on the following page in term of standard practices for your multi-series scripting:

    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, Yesterday, 11:48 AM
    0 responses
    8 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-25-2026, 09:53 PM
    0 responses
    10 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 03-25-2026, 09:51 PM
    0 responses
    8 views
    0 likes
    Last Post CaptainJack  
    Started by sjsj2732, 03-23-2026, 04:31 AM
    0 responses
    155 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    357 views
    0 likes
    Last Post NullPointStrategies  
    Working...
    X