Exp SafetyLock PRO
allows traders to avoid strong market reversals by setting an opposite order for an already opened position.
If a trader or an EA opens a position, SAFETYLOCK opens an opposite pending order for it. If the position becomes loss-making, the pending order is activated creating a lock.
The EA allows you to close the initial position, work with a trailing stop, or multiply the lot.
You can also modify the pending order Open price following the position price.
- The system monitors open orders on all pairs or only the ones specified in the EA settings (Symbol_Monitor);
- The system monitors positions placed in the Type_Monitor Expert Advisor;
- The system monitors the specified magic numbers (Magic_Monitor);
- A pending order is set at a distance of StopOrderDeltaifUSE from the current price;
- Then a pending order is monitored further;
- If StopOrderDeltaifUSE distance from an order is passed and ModifyOrdPend=true, pending order price is moved to breakeven;
- As soon as a pending order is activated, the EA starts monitoring it;
- The system allows you to disable the monitoring of orders. If SafetyPosMonitor=false, monitoring of positions opened by the EA is disabled;
- If true, the system monitors its pending orders;
- If a pending order is not activated while an appropriate order is closed manually or otherwise, the pending order is automatically removed;
- The system allows you to multiply lots of pending orders (MNLOT). Suppose that an order is opened with 0.2 lots. This means that a pending order is opened with 0.2 * MNLOT lots;
- If CloseOneifStopsActive=true, position (an appropriate pending order was opened for) is closed. Only position opened by the EA remains;
- Pending orders can be accompanied by StopLoss and TakeProfit;
- You can also enable a trailing stop (Tralling);
- No new pending orders are placed when resetting the terminal. Instead, it monitors the previously placed ones.
- ReopenClosedSafetyOrders - reopen Safety pending orders if they were closed by stops while the protected position is still open.
- NumberofStopOrder - number of pending orders placed for position
- DistancefromStopOrders - distance between the Safety orders
- CloseOneifStopsActive - Close the position if a Safety pending order was triggered
- Min_Lot_Monitoring - Minimum lot size to be monitored by the EA, if 0 - disabled;
- Max_Lot_Monitoring - Maximum lot size to be monitored by the EA, if 0 - disabled;
for example, you need to use the SafetyLock EA to protect positions, that accumulated lot size, for example, after using martingale. The lot for placing the opposite stop order is 0.16. At the same time, the EA is no supposed to affect positions less than 0.16. So you need to set the parameters as follows: Min_Lot_Monitoring =0.16;
for example, you need to lock all positions that have a lot size from 0.1 to 0.25. So you need to set the parameters as follows: Min_Lot_Monitoring = 0.1; Max_Lot_Monitoring = 0.25;
When set to AutoSetMinLevel, the stop levels will be reduced to the minimum possible levels, allowed on the server;
When set to ManualSet, user will receive a message, which says the stop levels of the EA are less than the minimum and the EA will stop trading.
- CloseSafetyPositionsifclosed - Close Safety positions that are activated, if the main position was closed.
For example, Close_One_if_Safety_Closed_In_Profit=true MNLOT=2.
As soon as the LOCK triggers and the Safety position closes by take profit, the original position will be closed.
- Added the Close_One_if_Safety_More_profitable parameter, which closes the original position, if the Safety position is more profitable, covering the current loss of the original position.
For example, Close_One_if_Safety_More_profitable=true MNLOT=2.
As soon as the LOCK triggers and the Safety position is more profitable, both the Safety and the original positions will be closed.
- Added the ModifyOrdPend_STEP pending - trailing step for pending orders when the ModifyOrdPend function is enabled
- Added the MilliSecondsTimerForMonitoring parameter - the number of milliseconds of the algorithm execution (by default, 1000 = 1 second)
- The Magic_Monitoring parameter has been updated. It is now possible to specify a list of magic numbers (separated by a comma) to be monitored.
Magic_Monitoring= -1 means that all magic numbers will be monitored
Magic_Monitoring= 0 means that manual trades will be monitored
Magic_Monitoring= 555,777 means that magic numbers 555 and 777 will be monitored
- Added monitoring filtering by the Comment_Monitoring comment. This option filters deal for placing locks for positions with the comment matching Comment_Monitoring
Comment_Monitoring="" - monitors all trades, regardless of the comment
Comment_Monitoring="VirtualTRadePad" - monitors all trades with the VirtualTRadePad comment, even if the comments contain VirtualTRadePad-1 or VirtualTRadePadEXTRA or TickVirtualTRadePadEXTRA
- Added a breakeven function
MovingInWLUSE - transfer the position to breakeven;
LevelWLoss - transfer the stop loss to +LevelWLoss points;
LevelProfit - when the trade gains LevelProfit points of profit;
- Fixed the error with placing pending orders on their positions when the SafetyPosMonitoring is enabled and more than 1 position in different directions are present in the market.
- Fixed the error with Magic_Monitoring, when setting a Magic_Monitoring value other than "-1"
The EA made this error in such functions as: CloseOneifStopsActive, Remove_TAKEPROFIT_ofOriginalifStopsActive, Remove_STOPLOSS_ofOriginalifStopsActive
- Fixed the error with modification of Take Profit when using the ModifyOrdPend parameter
- Added two options:
Remove_TAKEPROFIT_ofOriginalifStopsActive - remove the take profit of the original position, if the SafetyLock pending order was triggered;
Remove_STOPLOSS_ofOriginalifStopsActive - remove the stop loss of the original position, if the SafetyLock pending order was triggered;
It allows to "hard" lock two positions by removing the stop loss and take profit. It creates a "safe lock", which will not be unlocked if the original position was closed by its stop loss or take profit.
Details on the panel in our blog: https://www.mql5.com/en/blogs/post/687140
Min_Lot_Monitoring - minimum lot for the EA to monitor, if 0 - parameter is disabled;
Max_Lot_Monitoring - maximum lot for the EA to monitor, if 0 - parameter is disabled;
For example, you need to use the current SafetyLock EA for protecting positions which accumulated a large lot, such as after using martingale. The lot for which an opposite stop order should be placed = 0.16, at the same time the EA must not touch the positions less than 0.16. To do that, set the parameter to: Min_Lot_Monitoring =0.16;
For example, you need to lock all positions with lot sizes from 0.1 to 0.25, to do that, set the parameters to:
Min_Lot_Monitoring = 0.1;
Max_Lot_Monitoring = 0.25;
Added the SetMinStops variable:
In case of AutoSetMinLevel, the stop levels are reduced to the minimum possible levels, allowed on the server;
In case of ManualSet, user receives a message that the stop levels in the EA are less than the minimum allowed ones, and the EA stops operation.
Added the CloseSafetyPositionsifclosed variable:
Close SAFETY positions that have been activated, if the main position was closed.
ReopenClosedSafetyOrders - reopen the 'Safety' pending orders, if they were closed by a stop order, while the protected position is still open.
NumberofStopOrder - the number of pending orders placed for a position.
DistancefromStopOrders - the distance between the 'Safety' orders
CloseOneifStopsActive - Close the position if the 'Safety' pending orders was triggered
SymbolMonitoring = ALL_SYMBOL = Monitor all symbols, all trades on the account. If you placed the EA on 1 chart of any currency pair, then it will monitor every currency pair on the account;
SymbolMonitoring = ONLY_CURRENT_SYMBOL = Monitor only the current symbol. The EA will monitor and maintain only trades on the symbol the EA is set on;
SymbolMonitoring = SPECIFID_SYMBOL = Monitor only the trades on the symbol specified in SPECIFID_Symbol_Monitor. For example, EURUSD - then the EA will only maintain the trades on the EURUSD symbol;