I have plan to Handle scenarios may cause Expert malfunctioning.
This is Error codes may return in the run time. However, I want to handle these errors and some may not even Return errors.
I made this topic to be a start point for something big and every one who is willing can contribute.
I will Update This When we found an acceptable solution.
1- First Error That I encountered is Market closed with error code #4756. I noticed Ontick function Event still triggered When Market is Closed and this is strange!
when Ea attempt to close position it returns this error.
solution: skip ticks when you get 4756.
solution 2: Check market status on every tick or when you want to close position if it is closed so return.
scenario 2-Internet Connection failed and you have open orders.
Scenario 3: Wide Spread, on rollover and news hour and holidays some brokers( if not all) widening their spread.
Senario 4: ERR_TRADE_DISABLED, simply check in OnInit
senario 5: ERR_TRADE_SEND_FAILED
I will add more scenarios and you are welcome to contribute.'
A market can be closed for trading but still be open with active quote prices being reported with ticks coming in. You can review this in the symbol's contract specifications.
So, use the functions SymbolInfoSessionTrade() and SymbolInfoSessionQuote(), to obtain this information and prevent placing orders when the trading sessions are closed.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.