Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi instrument simulations

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

    Multi instrument simulations

    I define the variables:

    const int nSyms = 10;
    string[] symbols = {"$AUDUSD", "$EURUSD", "$GBPUSD", "$NZDUSD", "$USDCAD", "$USDCHF", "$USDHKD", "$USDJPY", "$USDNOK", "$USDSGD"};

    And then add the instruments in the Initialise() function as follows:

    Code:
           protected override void Initialize()
            {
                CalculateOnBarClose = true;
                
                Print("Instruments.GetLength(0) = " + Instruments.GetLength(0));
                for(int i=0; i < Instruments.GetLength(0);i++) {
                    Print("Instruments["+i+"].FullName = " + Instruments[i].FullName);
                }
                for (int i=0;i<nSyms;i++) {
                    // only add the non-primary series
                    Print("Attempting to add symbol " + symbols[i]);
                    Print("    primary is " +  Instruments[0].FullName);
                    if(0 != String.Compare(symbols[i], Instruments[0].FullName)){
                        Add(symbols[i], PeriodType.Minute, 5);
                        Print("    added " + symbols[i]);
                    }
                    else {
                        Print("    this is the primary series.");
                    }
                }
                Print("Number of instruments is " + Instruments.GetLength(0));
                for(int i=0; i < Instruments.GetLength(0);i++) {
                    Print("Instruments["+i+"].FullName = " + Instruments[i].FullName);
                }
    }
    When I do a backtest, I select an instrument from right pane of the strategy analyser window. I (incorrectly) expected that the instrument I select here would be the "primary data series" - but it is not.

    If I right click on "$AUDUSD" to bring up the backtest dialogue, the Initiase function runs, and the output is:

    Instruments.GetLength(0) = 1
    Instruments[0].FullName = $GBPUSD
    Attempting to add symbol $AUDUSD
    primary is $GBPUSD
    added $AUDUSD
    Attempting to add symbol $EURUSD
    primary is $GBPUSD
    added $EURUSD
    Attempting to add symbol $GBPUSD
    primary is $GBPUSD
    this is the primary series.
    Attempting to add symbol $NZDUSD
    primary is $GBPUSD
    added $NZDUSD
    Attempting to add symbol $USDCAD
    primary is $GBPUSD
    added $USDCAD
    Attempting to add symbol $USDCHF
    primary is $GBPUSD
    added $USDCHF
    Attempting to add symbol $USDHKD
    primary is $GBPUSD
    added $USDHKD
    Attempting to add symbol $USDJPY
    primary is $GBPUSD
    added $USDJPY
    Attempting to add symbol $USDNOK
    primary is $GBPUSD
    added $USDNOK
    Attempting to add symbol $USDSGD
    primary is $GBPUSD
    added $USDSGD
    Number of instruments is 10
    Instruments[0].FullName = $GBPUSD
    Instruments[1].FullName = $AUDUSD
    Instruments[2].FullName = $EURUSD
    Instruments[3].FullName = $NZDUSD
    Instruments[4].FullName = $USDCAD
    Instruments[5].FullName = $USDCHF
    Instruments[6].FullName = $USDHKD
    Instruments[7].FullName = $USDJPY
    Instruments[8].FullName = $USDNOK
    Instruments[9].FullName = $USDSGD
    Why is $GBPUSD the Instruments[0].FullName in this case?

    Thanks,
    Matthew.

    #2
    Matthew, there's no instrument set in the Initialize() as it will be set on the first OnBarUpdate() call - http://www.ninjatrader-support.com/H...tFullName.html
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rajendrasubedi2023, Today, 09:50 AM
    2 responses
    12 views
    0 likes
    Last Post rajendrasubedi2023  
    Started by geddyisodin, Today, 05:20 AM
    4 responses
    28 views
    0 likes
    Last Post geddyisodin  
    Started by geotrades1, Today, 10:02 AM
    2 responses
    8 views
    0 likes
    Last Post geotrades1  
    Started by ender_wiggum, Today, 09:50 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by bmartz, Today, 09:30 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X