Reputation: 357
I have a simple backtest of below EA:
void OnTick()
{
double rsi = iRSI( Symbol(), PERIOD_M5, 14, PRICE_CLOSE, 0 );
int day = TimeDay( TimeCurrent() );
int hour = TimeHour( TimeCurrent() );
int min = TimeMinute( TimeCurrent() );
if ( day == 7
&& hour >= 9
&& hour < 11
) {
Print( Symbol(), " / ", PERIOD_M5, " rsi: ", (string) rsi );
}
}
However, the backtest log seems does not match with show in the chart as this image:
https://i.sstatic.net/MLpvI.png
Could you please give some explanation?
Upvotes: 1
Views: 518
Reputation: 1
Q : "Could you please give some explanation?"
Sure, your code calculates & updates a printed RSI(14)
-value (per-tick)
Kindly notice, that the previous bar 08:55 has finished with RSI(14)
-value well above the HLINE ~ 30%
(if in doubts, one can initially Print( iRSI( Symbol(), PERIOD_M5, 14, PRICE_CLOSE, 1 ) );
where you will see the "previous"-bar value numerically.
From about that value ( above ~ 30% ) the newly opened bar [0]
will start to "develop" the actual RSI(14)
-value, inside the new bar. So, initially, the values will "move" and the graph plots / redraws the line ( we can visualise each such change as a dot, marker or a Hi/Lo-range ), which is THE REASON, why we finally see a blue line fallen to the position, where the Close[0]
has "finished" upon exiting of the bar under review (the 09:00 one, at about the 09:04:59:9999 time).
Upvotes: 1