How can I find out (at init() e.g.) that Trade is Allowed (opt are set) even if market is closed or Server is busy?

 

HI,

How can I find out (at init() e.g.) that trade is allowed (terminal-options are set) even if the server is busy (or market closed?)?

IsTradeAllowed();

Returns true if the Expert Advisor is allowed to trade and trading context is not busy, otherwise returns false.
 

This is not an atomic check (subject to race conditions) but how about...


begin function

    repeat a few times or forever

       if  (!IsTradeContextBusy() ) return IsTradeAllowed(); // possible race condition

       wait a bit

    end repeat

    return false;

end function


or a bit neater but might get stuck...


while IsTradeContextBusy()

  wait a bit

end while

return IsTradeAllowed() // still possible race condition if IsTradeContextBusy becomes true at this exact moment
 
Well I would have expected a function or a flag which is set by the terminal option!
 
gooly:
Well I would have expected a function or a flag which is set by the terminal option!

I suspected as much, but couldn't tell for sure from your post. Isnt there a lot more threads avialable these days, so trade context less likely to be busy anyway? Unless doing high performance stuff, in which case MT4 platform might not be the best option?
Reason: