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

Exp_GStopLoss_Tm - MetaTrader 5 Expert | Forex Indicators Download - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

An Expert Advisor for closing all positions in case the total loss of these positions exceeds the stop loss level fixed in the input, or it is necessary to close all positions when the time interval fixed in the settings is exceeded. In a way, this EA acts as a global stop-loss function for all open positions at the same time. The fact of stop losses and orders to close positions is itself placed by the EA as relevant comments in the log file.

 //+------------------------------------------------------------------------+
//| Options for calculating losses |
//+------------------------------------------------------------------------+
enum loss modes {
  ENUM_PERCENT, //Loss percentage ENUM_CARRENCY //Loss in deposit currency unit }; //+---------------------------------------------------------+
//|Input parameters of EA indicator|
//+------------------------------------------------------------------------+
Enter LossMode LMode=ENUM_PERCENT; //Method to detect loss
Enter double stop loss = 20.0 ; //Stop loss level

The EA offers the option to close positions only after exceeding the time interval defined in its input variables:

 input boolean timetrading= true ; //Allow trading by time interval
Enter hour start H=ENUM_HOUR_0; //Transaction start (hour)
Enter the minute StartM=ENUM_MINUT_0; //Transaction starts (minutes)
Enter the end of hour H=ENUM_HOUR_23; //End of transaction (hour)
Enter minutes EndM=ENUM_MINUT_59; //End of transaction (minutes)

Provide two variables (hours and minutes) for the operation start time and two similar variables for the end time.

The default settings enable the Expert Advisor to trade for the entire trading session starting from 0:00, while all positions are closed at 23:59.

If the start time is later than the specified end time, the Expert Advisor will close the position at the specified time the next day.


Attachment download

📎 exp_gstoploss_tm.mq5 (32.08 KB)

Source: MQL5 #21341

Verification code Refresh