Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Instruments - Error when bar missing

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

    Multiple Instruments - Error when bar missing

    Hi

    I am writing a strategy with multiple instruments with End-Of-Day data.
    For statistic purposes I write the price data of the instruments into an arraym whenever BarsInProgress=0:
    for (int x=0; x<instrumentcount;x++)
    {
    InstrdataArr[x,CapitalArrCount].Date = Times[x][0];
    InstrdataArr[x,CapitalArrCount].Open = Opens[x][0];
    InstrdataArr[x,CapitalArrCount].High = Highs[x][0];
    InstrdataArr[x,CapitalArrCount].Low = Lows[x][0];
    InstrdataArr[x,CapitalArrCount].Close = Closes[x][0];
    }


    This works fine as long each instrument has on all day price data. But an error is returned, when for one instrument a day is missing.
    Example Instrument 0:
    22.10.2010: 55.00
    23.10.2010: 56.00
    24.10.2010: 58.00

    Instrument 1:
    22.10.2010: 24.50
    24.10.2010: 23.00

    when OnBarUpdate is on Bar with 23.10.2010 for instrument 0 and I try to access e.g. Times[1][0] for instrument 1, I get an error "ou are accessing an index with a value that is invalid since its out of range."

    As I understand Bar 1 is 22.10.2010 for all instruments, Bar 2 is 23.10.2010 for instrument 0 and 24.10.2010 for instrument 1.
    Is this correct?

    How can I find out and catch the error? In such a case I simply would take on 23.10.2010 for instrument 1 the price data of the previous day.

    thanks for your feedback

    #2
    Hello Beauregard,

    Use prints to find which index is an invalid index by comparing the array.Count with the index.



    Each added series you are checking must have at least 1 bar.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hi
      thanks for the feedback.
      I do not really understand what you mean with "prints". You mean print to the console? How would this solve the problem?
      My statement Times[1][0] (beeing at BarsinProgress==0 and Date==23.10.2010) returns an error.

      Comment


        #4
        Hello Beauregard,

        Below is a link to a forum post with details about using Prints to the Output window to understand behavior and find errors.
        https://ninjatrader.com/support/foru...121#post791121

        What is the invalid index being used? What is the count of that array or collection?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cre8able, Today, 01:16 PM
        2 responses
        9 views
        0 likes
        Last Post cre8able  
        Started by chbruno, 04-24-2024, 04:10 PM
        3 responses
        48 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by samish18, Today, 01:01 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by WHICKED, Today, 12:56 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by WHICKED, Today, 12:45 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X