Put this code in the OnInit() function...
nATRHandle = iATR(_Symbol, PERIOD_CURRENT, nATRPeriod);
Comment(CopyBuffer(nATRHandle, 0, 0, 2, arrATR));
If you run this in a live chart, you'll see exactly what you expect... CopyBuffer returns 2. If you run it on a backtest, you'll see CopyBuffer returns -1. An error code. You'll see CopyBuffer returns -1, which is an error code. Why can we not access indicators in OnInit()... wouldn't that be kind of useful? (it took me hours to figure out why this wasn't working)
Why can we not access indicators in OnInit()
wouldn't that be kind of useful?
(it took me hours to figure out why this wasn't working)
Sorry that happened. At least you won't do it again.
Who told you that ?
This is not a bug, it's how MT5 is working.
Don't use this code in OnInit(), the tester doesn't have time to launch the indicator.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.