questions on EA run timelimits and deinit() always running - IF system for any reason pulls plug on EA

 

hello all MQLers

i ask as confused over writings about 2.5s cutoff and deinit() handling.

these are worries bout 24/7 unattended EA workings and trying cover all possibilities can think of - lol

ok, i been dream bout this much - not any way clear in mind, on mql4 info - needing help, as running of deinit() is most important for my EA

maybe no issue - not know so must try describe below a possible event series for u to see wat in my mind?... :)

.

example:

execution errors such as 6,129,130,134,136 and also vip for my work is runtime error 4066

i read they mostly all should need wait time b4 retry and 5s or maybe more needed

.

(X) EA has rule that ANY 'issue' like (3) which causes deinit() entry means that 100% cleanup done

eg, clear out all Trade Pool orders belong to EA + logging to disc files + Print()s + flush/close disc files + maybe do (Y) [1big or 10small?] ...

this could maybe take >2.5s ?

.

(Y) perhaps better to not only do its logging when ok tradeOperation done but also send Email ???

a kinda 'offsite' backup log which can always get to and so do manual MarketOrder closure... if can get online of course ;)

i worry if should do 1big email if sequential tradeOperations done or 1small email as each done ok.

ie, if concatenate or watevr each tradeOperation email text 'waiting' until all done b4 sending email - maybe EA get chopped b4 email sent... but if do loop of: tradeOperation -> send email; this maybe wasting time sending emails when should be only concentrate on getting orders out of TradePool... i think is catch 22 ?

.

(Z) guess all depends on ur feedback but 'what if' EA had Sleep() policy of not do one long Sleep() but break down into loop of: short Sleep() + check system state; so can react faster to any system state change needing start() to return() immediately.

.

(0) let us assume EA at time of (1) already has 10 open/active market orders on 10 sym,period combinations

(1) EA now wanna do #11 marketOrder and gets invalid price/129 so need sleep b4 retry

(2) EA enter Sleep(5000)

(3) maybe, say sometime after (2) started, system decides pull plug on EA - for watevr reason

(4) wat happen when (3), and EA code at (2) ?

  • (a) does Sleep() get aborted and EA code continues from next instruction after Sleep() call ?
  • (b) if (a) - is EA responsibility to findout that (3) state is say disabled/disconnected/stopped/system shutdown.... and if so, it immediately return(..) so that deinit() get run and do (X) ?
  • (c) if Sleep() not aborted and how many of 5s?, go by this is maybe >=2.5s (or if less, maybe taken off of 2.5s value?) - will system abort EA without anymore code workings after (2)? and since >=2.5s will deinit() still be called so can do (X)? and if still called how much time have ?
  • (d) if (c) wat if (X) takes time cuz 10 trade orders maybe take time to close + logging (Y)... (this assume can make tradeOperation calls/comms ok and not the error) is it gonna be chopped dead cuz not get to its return(..) in time ?

well, i appreciate much u getting down here :) and so much like hear from others on their understandings about this deinit() calling AND just how much time it gonna be allowed to have for (X) if any at all...

Best to all