I was searching in https://www.mql5.com/en/articles/239 and found this explanation:
The Calculation of Indicators During Testing
In the real-time mode, the indicator values are calculated at every tick. The Strategy Tester adopted a cost-effective model for calculating indicators - indicators are recalculated only immediately before the running of the EA. It means that the recalculation of the indicators is done before the call of the OnTick(), OnTrade() and OnTimer() functions.
It does not matter whether or not there is a call for the indicator in a specific event handler, all of the indicators, the handles of which were created by the iCustom() or IndicatorCreate() functions will be recalculated before calling the event handler.
Consequently, when testing in the "Every tick" mode, the calculation of the indicators takes place before the call of OnTick() function.
If the timer is on in the EA, using the EventSetTimer() function, then the indicators will be recalculated before each call of the OnTimer() handler. Therefore, the testing time can be greatly increased with the use of an indicators, written in a non-optimal way.
If the indicator is recalculated only before the EA running, how do I test EA with custom indicators?
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
I'm using the last version of MT5 (build 1881) and I'm having some troubles in strategy tester with a custom indicator with 7 buffers. The indicator works perfectly when I put it in the chart and works fine too when I put it in an EA and runs the advisor in real time mode. When I run the EA in strategy tester with the custom indicator, the CopyBuffer method copy the first buffer to all other buffers.
This is the EA code (Print returns the same value to all buffers):
This is the Custom Indicator code:
This is the image of the visualization mode. The buffers are loaded just in the bars before the start test date.
If I call the iCustom method in OnTick, the returned values are correct, but the EA run slowly. If I add other default indicators like iBands and iADX, the buffers are seted correctly.