OrderHistoryTotal()-Results on a new account ?
Do not use MarketInfo/OrdersHistoryTotal in init because the parameters/values may not yet be loaded. Wait for start/OnTick.
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.
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?