Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

1 Click to Close All Open Positions in the Current Attached Chart - MetaTrader 4 Expert - MT4/MT5 Resource

author EAcpu | 5 reads | 0 comments |

1 Click To Close All Open Positions at Current Attached Chart - expert for MetaTrader 4

Click the "Close All" button to close all open positions currently in the attached chart.

Select Close Manual Trading Only = True Only Manual Trading is Closed.

Choosing to close only manual trades = incorrectly closing manual trades and/or other trades opened by the Expert Advisor.

This new version does not contain the previous version of code written below which could cause an infinite loop.

 if (view order closed == false ) continue ;

But instead brought in an error control system to prevent infinite loops while still closing all transactions.

 if (check order closed == false )
        {
integer error code = get last error ();
  
if (errorcode== 1 ||errorcode== 2 ||errorcode== 5 ||errorcode== 6 ||errorcode== 64 ||errorcode== 65 ||errorcode== 132 ||errorcode== 133 ||errorcode== 139 ) rest ;
Continue with others ; 
               } 

1 Click To Close All Open Positions at Current Attached Chart - expert for MetaTrader 4


Attachment download

📎 1clickcloseallv02.mq4 (4.84 KB)

Source: MQL5 #14869

Verification code Refresh