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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X