Somewhere in the docs it says
It is not recommended to store important market characteristics in the function init(), it is better to request market conditions in a place of use and it is obligatory to check them on empty/zero values. Otherwise, an attempt of starting a script on inactive accounts may result in receiving the wrong values.
Do not use MarketInfo/OrdersHistoryTotal in init because the parameters/values may not yet be loaded. Wait for start/OnTick.
WHRoeder:
Somewhere in the docs it says
Somewhere in the docs it says
Do not use MarketInfo/OrdersHistoryTotal in init because the parameters/values may not yet be loaded. Wait for start/OnTick.
Yes I know that - but it's a very stupid situation: Don't use OnInit() as is may not initialize all.
But even in OnTick/start you have to do:
bool INI = false: ... void OnTick(){ if ( !INI ) { if ( OrdersHistoryTotal() <=0 ) return; INI = true; } }
and that mean you have to write different code for debugging and the strategy-tester.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
The Doc. of mt4 tells me:
But if there is a new account there won't be any orders (closed or open) just the deposit is booked.
On the other hand if an EA is started e.g. by an automatic restart of the terminal after a crash of what ever its functions OnTick() and OnInit() are started while the parameters aren't loaded like MarketInfo(Symbol(),MODE_TICKVALUE) - which is of course not desirable. :(
I found that if I wait by:
I can be sure that all parameters are loaded - but a new account has not orders?
But may be the initial money deposit is counted as 'closed order' - is that true?