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

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'
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by llanqui, Today, 03:53 AM
    0 responses
    4 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Working...
    X