PDA

View Full Version : Bug: Strategy Analyser, Backtest, Min. Bar required


David Lean
12-06-2009, 12:13 AM
Version 6.5.1000.14

When Running a Backtest in Strategy Analyzer it appears that the "Min. Bars required" parameter is not passed correctly to indicatiors displayed in a Strategy. Reguardless of its Min Bars value the Indicators remain set to 20.

Steps to Reproduce.
1. I added 2 lines in the Initialize() method
Add(SMA(sMAFast));
SMA(sMAFast).Plots[0].Pen.Color = Color.Green;
SMA(sMAFast).Plots[0].Pen.Width = 2;
SMA(sMAFast).Plots[0].Pen.DashStyle = DashStyle.Dash;

Add(SMA(sMASlow));
SMA(sMASlow).Plots[0].Pen.Color = Color.Black;
SMA(sMASlow).Plots[0].Pen.Width = 3;

I set the Periods to 1 & 2 respectively. So they should draw immediately.

2. All added lines start to be visible on the 21st Bar in the Chart Tab.

If I change the Strategy's "Min. Bars required" parameter. The starting position of the added lines remains the same.

I tried setting "Min. Bars required" = 1 & also to 100. The Strategy does correctly start trading on the bar required. But the Visual Indicators all seem to remain at 20.

Is this a bug or is this by design?

NinjaTrader_Ben
12-06-2009, 10:57 AM
Hello,

If I recall, you can use BarsRquired = 1 in the initialization to get what you want. The setting you are changing changes the strategy executions only. This link should help:
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html

Post a reply if that does not work and I'll have someone assist you on Monday.

werido
12-17-2009, 12:33 PM
Hi, what exactly does this parameter mean? If I'm running a strategy that would enter a trade and exit based all on crossover of an indicator, what relevance does min bars required have to that strategy? Does it mean that if the crossover to exit occurs before say 20 bars are plotted (I assume that would translate to 20 minutes on a 1 minute chart) then the strategy won't execute if the min bars required is set to 20? Or does it mean that the strategy won't even enter on the crossover if the chart doesn't have at least 20 minutes plotted on it, but it will all run fine so long as the chart is loaded with at least 20 minutes (1 min charts)? Or does there have to be 20 more bars that plot once the strategy is turned on?
Thanks.

NinjaTrader_Josh
12-17-2009, 01:08 PM
It does what its name sounds like. It means your strategy does not start till it has 20 bars minimum. Once it reaches having 20 bars on the chart, then it starts processing its strategy logic.

werido
12-17-2009, 01:25 PM
But does the strategy start if there are 20 bars plotted on the chart when you apply the strategy to the chart? Or does there have to be 20 more bars drawn after you apply a strategy for the strategy to begin operating? Or does it force a global rule on the strategy that there has to be 20 bars between open and close of a trade?
Thanks.

NinjaTrader_Austin
12-17-2009, 01:38 PM
The strategy will start if there are 20 bars on the chart when the strategy is applied.

werido
12-17-2009, 01:56 PM
ok, thanks a million!