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 jclose, Today, 09:37 PM
    0 responses
    6 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,414 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Today, 08:53 PM
    0 responses
    11 views
    0 likes
    Last Post firefoxforum12  
    Started by stafe, Today, 08:34 PM
    0 responses
    11 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by sastrades, 01-31-2024, 10:19 PM
    11 responses
    169 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X