Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Instrument Strategy not running on all instruments.

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

    Multi-Instrument Strategy not running on all instruments.

    Hi I am facing an issue where my strategy script doesn't seem to be running on all of the instruments that I have added in my configure section. I have checked and the instruments added to the strategy do have data so I'm not sure why they aren't working:

    Here is the code responsible for the output:
    protected override void OnBarUpdate()
    {

    for (int i = 0; i < 1l; i++)
    {
    if (BarsInProgress == i)
    {
    Print("CurrentBars: " + CurrentBars[i] + "instrument Number: " + i);

    }

    if (CurrentBars[i] < 122)
    {

    return;
    }

    }


    Here is the instruments being added to the script in configure:
    else if (State == State.Configure)
    {
    AddDataSeries("NQ 03-23", BarsPeriodType.Minute, 15);
    AddDataSeries("CL 04-23", BarsPeriodType.Minute, 15);
    AddDataSeries("6B 03-23", BarsPeriodType.Minute, 15);
    AddDataSeries("6J 03-23", BarsPeriodType.Minute, 15);
    AddDataSeries("NG 04-23", BarsPeriodType.Minute, 15);
    AddDataSeries("YM 03-23", BarsPeriodType.Minute, 15);
    AddDataSeries("GC 04-23", BarsPeriodType.Minute, 15);
    AddDataSeries("ZB 06-23", BarsPeriodType.Minute, 15);
    AddDataSeries("6A 03-23", BarsPeriodType.Minute, 15);
    AddDataSeries("ZS 05-23", BarsPeriodType.Minute, 15);
    AddDataSeries("SI 05-23", BarsPeriodType.Minute, 15);
    }


    Here is the Output:

    CurrentBars: 106instrument Number: 0
    CurrentBars: 107instrument Number: 0
    CurrentBars: 108instrument Number: 0
    CurrentBars: 109instrument Number: 0
    CurrentBars: 110instrument Number: 0
    CurrentBars: 111instrument Number: 0
    CurrentBars: 112instrument Number: 0
    CurrentBars: 113instrument Number: 0
    CurrentBars: 114instrument Number: 0
    CurrentBars: 115instrument Number: 0
    CurrentBars: 116instrument Number: 0
    CurrentBars: 117instrument Number: 0
    CurrentBars: 118instrument Number: 0
    CurrentBars: 119instrument Number: 0
    CurrentBars: 120instrument Number: 0
    CurrentBars: 121instrument Number: 0
    CurrentBars: 122instrument Number: 0
    Strategy 'GapFillLive': Error on calling 'OnBarUpdate' method on bar 122: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.​

    #2
    Hello BachDCDM,

    It looks like your code is producing an error so that may be why. I would suggest removing all of the code you have shown from OnBarUpdate and just use a Print to see which indexes are being processed:

    protected override void OnBarUpdate()
    {​
    Print(BarsInProgress + " " + Instrument.FullName);

    That would let you know all of the BarsInProgress indexes that are getting processed'

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    83 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    143 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    83 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    256 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    334 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X