Why MQL4 Backtest RSI values do not match with RSI on chart?

Why MQL4 Backtest RSI values do not match with RSI on chart?

Manage alerts

Loading saved threads...

dvn0zzz · External communityPost link
External question — Stack Overflow Stack Exchange Author: dvn0zzz Original post: https://stackoverflow.com/questions/65219267 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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?
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: user3666197 Original post: https://stackoverflow.com/a/65222187 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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).
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: dvn0zzz Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/65219267 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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?

Cancel quote

Checking account access…