Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi instrument strategy not showing backtest

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

    Multi instrument strategy not showing backtest

    Hello,

    I experience strange behavior. I have multi instrument strategy and when I try to load it on chart to see backtest data nothing is shown.

    The strange thing is, that is happens only when the strategy has around 30 Add() clausules in Initialize().

    When I add only few additional instruments everything is shown correctly.

    Is there any limit to how many instruments you can add to script? Or is there any other explanation for this? Thanks in advance for answer and help.

    #2
    Hello Waldo,

    Thank you for your post.

    There is no limitation on how many bar series can be added. However, it is likely that the CurrentBars are not being checked before accessed. Information on this can be found at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

    However, you would need to use CurrentBars for each bar series: http://www.ninjatrader.com/support/h...urrentbars.htm

    Please let me know if you have any questions.

    Comment


      #3
      Multi Instrument strategy not firing

      Morning guys. The following code for single timeframe multi-instrument strategy is not firing - any ideas why that might be?



      protected override void Initialize()
      {
        

      {
      Add("PG", PeriodType.Minute,390);
      Add("CVX", PeriodType.Minute,390);
      Add("IBM", PeriodType.Minute,390);
      Add("GE", PeriodType.Minute,390);
      Add("XOM", PeriodType.Minute,390);
      Add("T", PeriodType.Minute,390);
      Add("JNJ", PeriodType.Minute,390);
      Add("PFE", PeriodType.Minute,390);
      Add("WFC", PeriodType.Minute,390);
      Add("PM", PeriodType.Minute,390);
      Add("KO", PeriodType.Minute,390);
      Add("MRK", PeriodType.Minute,390);
      Add("VZ", PeriodType.Minute,390);
      Add("SLB", PeriodType.Minute,390);
      Add("WMT", PeriodType.Minute,390);
      Add("MCD", PeriodType.Minute,390);
      Add("PEP", PeriodType.Minute,390);
      Add("COP", PeriodType.Minute,390);
      Add("C", PeriodType.Minute,390);
      Add("ABT", PeriodType.Minute,390);
      Add("OXY", PeriodType.Minute,390);
      }





      EntryHandling = EntryHandling.UniqueEntries;
      EntriesPerDirection = 1;
      CalculateOnBarClose = false;
      TraceOrders = true;
      ExitOnClose = true;
      TimeInForce = Cbi.TimeInForce.Gtc;
      DefaultQuantity=100;

      }
      protected override void OnBarUpdate()
      {


      if (BarsInProgress != 0)
      return;

      if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired ||
      CurrentBars[3]<= BarsRequired || CurrentBars[4] <= BarsRequired || CurrentBars[5] <= BarsRequired
      || CurrentBars[6] <= BarsRequired || CurrentBars[7] <= BarsRequired ||
      CurrentBars[8]<= BarsRequired || CurrentBars[9] <= BarsRequired || CurrentBars[10] <= BarsRequired ||
      CurrentBars[11] <= BarsRequired || CurrentBars[12] <= BarsRequired || CurrentBars[13] <= BarsRequired
      || CurrentBars[14] <= BarsRequired || CurrentBars[15] <= BarsRequired ||
      CurrentBars[16]<= BarsRequired || CurrentBars[17] <= BarsRequired || CurrentBars[18] <= BarsRequired ||
      CurrentBars[19]<= BarsRequired || CurrentBars[20] <= BarsRequired || CurrentBars[21] <= BarsRequired

      )


      Print ("Data Error");
      return;



      if (Position.MarketPosition == MarketPosition.Flat
      && PriorDayOHLC().PriorOpen[0] < PriorDayOHLC().PriorClose[0]
      && (CurrentDayOHL().CurrentOpen[0] - PriorDayOHLC().PriorClose[0]) > (DailyATR(5)[0]*0.1)
      && ((CurrentDayOHL().CurrentOpen[0] - PriorDayOHLC().PriorClose[0]) <= (DailyATR(5)[0]*0.7))
      && CurrentDayOHL().CurrentOpen[0] > PriorDayOHLC().PriorHigh[0]
      && Bars.FirstBarOfSession
      && Bars.TickCount <1000)

      {
      EnterShort(100, "SP STOCKS Short");
      }


      {
      SetStopLoss("SP STOCKS D-OC Short", CalculationMode.Price, ((DailyATR(5)[0]*0.7) + CurrentDayOHL().CurrentOpen[0]) , false);
      SetProfitTarget ("SP STOCKS D-OC Short", CalculationMode.Price, ((PriorDayOHLC().PriorClose[0])));
      }

      Comment


        #4
        Hello everington_f,

        Thank you for your post.

        It could be the condition, I would check this with a Print() as well. For example:
        Code:
        if (Position.MarketPosition == MarketPosition.Flat 
        && PriorDayOHLC().PriorOpen[0] < PriorDayOHLC().PriorClose[0] 
        && (CurrentDayOHL().CurrentOpen[0] - PriorDayOHLC().PriorClose[0]) > (DailyATR(5)[0]*0.1)	
        && ((CurrentDayOHL().CurrentOpen[0] - PriorDayOHLC().PriorClose[0]) <= (DailyATR(5)[0]*0.7))
        && CurrentDayOHL().CurrentOpen[0] > PriorDayOHLC().PriorHigh[0] 
        && Bars.FirstBarOfSession
        && Bars.TickCount <1000)
        
        {
        Print(Time[0] + " Enter Short");
        EnterShort(100, "SP STOCKS Short"); 
        }

        Comment


          #5
          Thankyou for the reply and I will try your suggestion. The condition works on single Futures instruments so I am puzzled as to why it will not fire on multiple stocks.

          Comment


            #6
            I get the message Data Error which tells me I do not have enough bars loaded in the array. I checked the historical data manager and there appears to be enough data there for the 20 stocks i am looking at. I use IB and their servers.

            When I use:

            Print (BarsRequired)

            I get 15 in the output window... not the 30 that I stipulate in the GUI....


            PROBLEM SOLVED.... i needed to have the correct exchange in the instrument manager list... default didnt work when loading the bars from IB
            Last edited by elliot5; 05-06-2015, 01:42 PM. Reason: update

            Comment


              #7
              Thank you for the update on this!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, Today, 05:29 AM
              0 responses
              3 views
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              27 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              36 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              218 views
              1 like
              Last Post PaulMohn  
              Working...
              X