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 StockTrader88, 03-06-2021, 08:58 AM
    45 responses
    3,991 views
    3 likes
    Last Post johntraderuser2  
    Started by TAJTrades, Today, 09:46 AM
    0 responses
    7 views
    0 likes
    Last Post TAJTrades  
    Started by rhyminkevin, Yesterday, 04:58 PM
    5 responses
    62 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by realblubb, Today, 09:28 AM
    0 responses
    8 views
    0 likes
    Last Post realblubb  
    Started by AaronKoRn, Yesterday, 09:49 PM
    1 response
    19 views
    0 likes
    Last Post Rikazkhan007  
    Working...
    X