Handling worst case senario may EA fail

Gholamhossein Eslamizadeh
162

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.

For Example:

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.'

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Runtime Errors
  • www.mql5.com
Runtime Errors - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Fernando Carreiro
9732

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.


Documentation on MQL5: Market Info / SymbolInfoSessionTrade
Documentation on MQL5: Market Info / SymbolInfoSessionTrade
  • www.mql5.com
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5