PDA

View Full Version : How to access price data more than 20 barsAgo


lewdfinger
02-11-2007, 10:02 PM
I want to compare the EMA(200)[0] to EMA(200)[40] or higher but when I assign the latter to a variable it comes up null - the most I can get is 20 bars ago.

Is there a way to increase the maximum number of bars one can reference?

protected override void OnBarUpdate()

{

Print(EMA(200)[20].ToString());

}
KD

NinjaTrader_Dierk
02-12-2007, 01:31 AM
There is no limitation on # of bars ago you can reference. You only need to make sure your CurrentBar index is greater than the lookback value, like

if (CurrentBar > 40)
Print(EMA(200)[40].ToString());