Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What defines how far back a strategy is applied?

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

    What defines how far back a strategy is applied?

    I have a strategy that operates on the 10 and 60 minute time frames. it seems to be working fine except that it doesn't go back very far. What defines how far back a strategy can be applied?

    here is my code if anyone needs to look at it.

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    
    namespace NinjaTrader.Strategy
    {
    
        [Description("THIS IS THE TEMPLATE FOR ALL MY NEW STRATEGIES")]
        public class SIMPLETRIPLESCREEN : Strategy
        {
            #region Variables
    		
    		private DataSeries HourlyCloses; //holds hourly data series
    		private DataSeries TenMinCloses; //holds Ten minute data series
    		double RcDeviation = 3.5;
    		
            #endregion
    
    
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
    			
    			Add(PeriodType.Minute, 60);
    			
    			TenMinCloses = new DataSeries(this); //sync primary ten minute series
    			
            }
    
    
            protected override void OnBarUpdate()
            {
    			double TenMinClose = Close[0];
    			double HourlyClose = Closes[1][0];
    			
    			string Direction = "UNKNOWN";
    			
    			bool SmaRising, MaUp;
    			
    			if(CurrentBars[0] <= BarsRequired ||
    				CurrentBars[1] <= BarsRequired)
    				return;
    			
    			//sync hourly data series
    			HourlyCloses = new DataSeries(SMA(BarsArray[1], 3));
    			
    			if(BarsInProgress ==0)
    			{
    				//check if SMA is rising on the longer term chart
    				if(Rising(SMA(HourlyCloses,25)))
    				{
    					SmaRising = true;
    				} 
    				else	SmaRising = false;
    				
    				//check is 8EMA is above 25SMA on the longer term chart
    				if(EMA(HourlyCloses, 8)[0] > SMA(HourlyCloses, 25)[0])
    				{
    					MaUp = true;
    				}
    				else	MaUp = false;	
    				
    				//check if ten minute price is at extremes
    				
    				
    				
    				//Determine directional bias--------------------------
    				if(SmaRising == true && MaUp == true)
    				{
    					Direction = "LONG";
    					
    					if(TenMinClose < RegressionChannel(150, RcDeviation).Lower[0] &&
    						Position.MarketPosition != MarketPosition.Long)
    					{
    						EnterLong();
    					}
    				}
    				else
    					if(SmaRising == false && MaUp == false)
    					{
    						Direction = "SHORT";
    						
    						if(TenMinClose > RegressionChannel(150, RcDeviation).Upper[0] &&
    							Position.MarketPosition != MarketPosition.Short)
    						{
    							EnterShort();
    						}
    					}
    					else	Direction = "UNKNOWN";
    					
    						if(Position.MarketPosition == MarketPosition.Long)
    						{
    							ExitLong();
    						}
    						else
    							if(Position.MarketPosition == MarketPosition.Short)
    							{
    								ExitShort();
    							}
    							else return;
    							
    				//----------------------------------------------------
    				
    						
    			}
    			
    			
            }
    
            #region Properties
            #endregion
        }
    }

    #2
    Ok i see that it has gone back several days.. i didn't scroll far enough to see the earlier entries. Sorry - i solved myown problem

    Comment


      #3
      Hi ShruggedAtlas,

      Data availability is determined by the data provider. You must first have the data before the strategy could use it.

      The date range of the strategy will depend on the time frame specified. If you run a backtest or from strategy tab of control center, there are Time frame settings to have it lookback further. If you run directly from a chart, it will use the chart's data, set in the Right Click > Data Series screen.

      There is also MinimumBarsRequired setting for the strategy. This minimum bars required must be satisfied for all series before the strategy will start submitting orders, etc.
      Ryan M.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X