When backtesting with indicators from different timeframes, the results can be off, because StrategyTester simply does not provide enough history. Here's a simple EA for testing, which displays the values of a few EMAs from the daily timeframe:
...and it's results: the error gets bigger, the longer the EMA period. The Stochastic is correct, as long as it's period does not exceed the available bars.
http://img65.imageshack.us/img65/265...problemdv0.png
I guess it's one of those MetaTrader quirks, but it would be nice if somebody has a solution. It does get somewhat better, by using an earlier start date, but that's inconvenient when testing a certain period and outright impossible at the beginning of available data.
Is there maybe some magic LoadHistory() command that I've missed?
PHP Code
void start()
{
//----
// Print daily EMAs of the last days
for(int i = 4; i >= 2; i--)
{
double ema5 = iMA(NULL,PERIOD_D1,5 ,0,MODE_EMA,PRICE_CLOSE,i),
ema20 = iMA(NULL,PERIOD_D1,20,0,MODE_EMA,PRICE_CLOSE,i),
ema50 = iMA(NULL,PERIOD_D1,50,0,MODE_EMA,PRICE_CLOSE,i),
stoch20= iStochastic(NULL,PERIOD_D1,25,3,3,MODE_SMA,0,0,i);
Print(TimeToStr(iTime(NULL,PERIOD_D1,i)),
": EMA5 = "+DoubleToStr(ema5,Digits),
", EMA20 = "+DoubleToStr(ema20,Digits),
", EMA50 = "+DoubleToStr(ema50,Digits),
", Stoch20= "+DoubleToStr(stoch20,Digits));
}
Print("Bars = "+iBars(NULL,PERIOD_D1));
}
http://img65.imageshack.us/img65/265...problemdv0.png
I guess it's one of those MetaTrader quirks, but it would be nice if somebody has a solution. It does get somewhat better, by using an earlier start date, but that's inconvenient when testing a certain period and outright impossible at the beginning of available data.
Is there maybe some magic LoadHistory() command that I've missed?