Backtesting takes too long
- You are obtaining the indicator handle on every tick. Don't!
Get it only once, in the OnInit() handler. - You are reading the buffer on every tick. Don't!
Read it only once per bar — Detecting the start of a new bar or candle
Detecting the start of a new bar or candle
- www.mql5.com
Detecting the start of a new bar or candle, in the OnTick() event handler of an expert advisor.
Fernando Carreiro #:
- You are obtaining the indicator handle on every tick. Don't!
Get it only once, in the OnInit() handler. - You are reading the buffer on every tick. Don't!
Read it only once per bar — Detecting the start of a new bar or candle
wow, I didn't know that it could be this simple.
I appreciate this, thank you a lot, sir!
Hello everyone, im struggling with backtesting EA. Normally when I backtest with visualized chart, it will run through smoothly. But with the code below, it doesn't do it quickly any more. Even if I just run the backtest without chart, it will eventually disconnect and stop the test after a few seconds
I tried to debug and found the problem comes form the line (ii>0). However, I don't know an alternative way to solve it.
1. I need (ii>0) or else, the EA will return the error of "rsi out of array"
2. If I add (ii>0 && ii<20) to limit the array, then it won't execute trades
Below is the code, i deleted all other unimportant functions. Please suggest me any changes should be applied for it