Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not enough bars for strategy when adding a third dataSeries

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

    Not enough bars for strategy when adding a third dataSeries

    Hello, I'm doing tests on a strategy and I tried to add a third dataseries of higher timeframe of the same instrument. It worked well so far using only 2 data series but I'm not able de get the amount of bar required to trade with the third one.

    here is the code i'm using :
    Code:
    ​        private Ichimoku ichimoku1;
            private Ichimoku ichimoku2;
            private Ichimoku ichimoku3;
    
    
            protected override void OnStateChange()
            {
                
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Ma stratégie perso made in Tessan Molinié";
                    Name                                        = "DTPStrategy_v2";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 1;            
                    BarsRequiredToTrade                            = 52+26;
                    IsUnmanaged                                 = true;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration    = false;
                }
                else if (State == State.Configure)
                {
                    //AddDataSeries(instruments[0], new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 60 }, 52+26, string.Empty, null);
                    AddDataSeries(BarsPeriodType.Minute, 15);
                    AddDataSeries(BarsPeriodType.Minute, 60);
    
                }
                else if (State == State.DataLoaded)
                {
                    ichimoku1 = Ichimoku(BarsArray[0]);
                    ichimoku2 = Ichimoku(BarsArray[1]);
                    ichimoku3 = Ichimoku(BarsArray[2]);
    
                    AddChartIndicator(ichimoku1);
                    AddChartIndicator(Pivots(BarsArray[0], PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 240));
                }
            }
    
            protected override void OnBarUpdate()
            {                    
                if(State == State.Historical) return;
    
                if (CurrentBars[0] < BarsRequiredToTrade)
                {
                    Print("Not enough bars in data serie 0");
                    return;
                }
                if(CurrentBars[1] < BarsRequiredToTrade)
                {
                    Print("Not enough bars in data serie 1");
                    return;
                }
                if(CurrentBars[2] < BarsRequiredToTrade)
                {
                    Print("Not enough bars in data serie 2");
                    return;
                }​

    #2
    Hello Tessan,

    Try adding more days of historical data to load so there are at least 78 60-minute bars processed before the script becomes realtime.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      How should I add more bars, by tweaking the BarsRequiredToTrade variable ?

      Comment


        #4
        Hello Tessan,

        The 'Days to load' property is in the Data Series window from the chart.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ah yes it worked! thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by samish18, Today, 09:30 PM
          0 responses
          6 views
          0 likes
          Last Post samish18  
          Started by Super Bardock, Yesterday, 11:52 AM
          2 responses
          21 views
          0 likes
          Last Post Super Bardock  
          Started by raysinred, 04-06-2025, 01:52 PM
          16 responses
          139 views
          0 likes
          Last Post raysinred  
          Started by iantriestrading, Yesterday, 01:39 PM
          5 responses
          28 views
          0 likes
          Last Post iantriestrading  
          Started by trendisyourfriend, 05-25-2023, 09:54 AM
          10 responses
          170 views
          0 likes
          Last Post Curerious  
          Working...
          X