Download MetaTrader 5

OnInit() and Optimization()

To add comments, please log in or register
stanislass
78
stanislass  
Hello

In "OnInit ()" I house the static part of the display of an EA to avoid refreshing it with each tick. To accelerate the optimization I use "IsOptimization ()" to display nothing.
I do not notice any difference of time between with and without. Is OnInit () executed at each optimization cycle or only once at the beginning of the process?

Thank
Fernando Carreiro
3952
Fernando Carreiro  
stanislass: In "OnInit ()" I house the static part of the display of an EA to avoid refreshing it with each tick. To accelerate the optimization I use "IsOptimization ()" to display nothing.
I do not notice any difference of time between with and without. Is OnInit () executed at each optimization cycle or only once at the beginning of the process?
OnInit() is run on every Optimisation pass/run, but during Optimisation, MetaTrader already disables all Chart and Display events, so you will not see much improvement in speed compared to disabling it yourself (unless you have heavy calculations associated with the updating of visual elements).

If it is still too slow for you, then maybe consider refactoring your code and only executing code section only when necessary, such as only on new bar events or only when price changes more than a certain amount, instead of on every tick.
stanislass
78
stanislass  

Okay, I understand better. Thank you for your clarification.

To add comments, please log in or register