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

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

author EAcpu | 3 reads | 0 comments |

An Expert Advisor for closing all positions in case the total profit of these positions exceeds the take profit level fixed in the input, or the total loss of these positions exceeds the stop loss level fixed in the input, or it is necessary to close all positions outside the time interval fixed in the settings. In a way, this EA acts as both a global take-profit function and a global stop-loss function for all open positions. 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 stop mode {
  ENUM_PERCENT, //Percentage of loss and profit ENUM_CARRENCY //Loss and profit expressed in deposit currency units }; //+-------------------------------------------------------------------------+
//|Input parameters of EA indicator|
//+------------------------------------------------------------------------+
Enter StopMode LMode=ENUM_PERCENT; //Method to detect losses and profits
Enter double stop loss = 20.0 ; //Stop loss level
Enter double take profit = 100.0 ; //Take profit 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_gstop_tm.mq5 (34.01 KB)

Source: MQL5 #21343

Verification code Refresh