Exp SafetyLock PRO
SAFETYLOCK 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.
- MilliSecondsTimerForMonitoring - the duration of algorithm execution, in milliseconds (default is 1000 = 1 second).
- SymbolMonitoring - SymbolMonitoring = ALL_SYMBOL = monitoring all symbols and all trades on the account. If you launch the Expert Advisor on any currency pair chart, it will monitor all currency pairs.
- Type_Monitoring - the type of trades for the EA to monitor, BUY SELL or ALL.
- Magic_Monitoring - the magic number of positions for the EA to monitor, you can specify multiple values separated by commas.
- Comment_Monitoring - this option filters trades for opening a locking position based on the Comment_Monitoring.
- Min_Lot_Monitoring - the minimum lot for the EA to monitor, the parameter is disabled if set to 0.
- Max_Lot_Monitoring - the maximum lot for the EA to monitor, the parameter is disabled if set to 0.
- SafetyPosMonitoring - enable monitoring of positions opened by the SafetyLock Expert Advisor.
- StopLosse - stop loss for SafetyLock pending orders.
- TakeProfite - take profit for SafetyLock pending orders.
- MNLOT - lot multiplier for pending orders.
- StopOrderDeltaifUSEe - the distance for SafetyLock pending orders.
- NumberofStopOrder - the number of SafetyLock pending orders per position.
- DistancefromStopOrders - the step of the order grid in points if you use NumberofStopOrder.
- ModifyOrdPend - enable pending order price modification based on the price movement. If enabled, pending orders will follow the price.
- ModifyOrdPend_STEP - order price modification step in pips.
- ReopenClosedSafetyOrders - reopen SafetyLock pending orders that were closed by a stop loss, if the locked position is still open.
- Close_One_if_Safety_Closed_In_Profit - close the original position if the SafetyLock position was closed with profit covering the current loss of the original position.
- Close_One_if_Safety_More_profitable - close the original position if the profitable SafetyLock position covers the current loss of the original position.
- CloseOneifStopsActive - close the position if the SafetyLock pending order triggers. Once a pending order triggers and turns into a position, the main position will be closed if this option is enabled.
- CloseSafetyPositionsifclosed - close SafetyLock activated positions after closing the main position.
- Remove_TAKEPROFIT_ofOriginalifStopsActive - delete the take profit of the original position upon the activation of the SafetyLock pending order.
- Remove_STOPLOSS_ofOriginalifStopsActive - delete the stop loss of the original position upon the activation of the SafetyLock pending order.
- TrailingStopUSE - enable trailing stop of SAFETYLOCK PRO positions. The trailing stop will only be activated for positions that triggered and were opened by the EA.
- IfProfTrail - trailing stop will only be enabled after the position reaches the TrailingStop number of points. If you disable this option the EA will enable the trailing stop function immediately after the position reaches +0 profit points. In this case the first stop loss is set in the losing zone.
- TrailingStart - the number of profit points to activate the trailing stop function.
- TrailingStop - distance in points from the current price to the set stop loss. If the current profit is 200 points, and TrailingStop = 100, then stop loss will be set at +100 points. Thus, we allow the price to move back to a maximum of 100 points. Otherwise the stop loss will trigger and the position will be closed at +100 points.
- TrailingStep - stop loss modification step in the trailing stop function.
- MovingInWLUSE - enable the breakeven function. The function modifies the stop loss level by LevelWLoss points once the position reaches the LevelProfit number of profit points.
- LevelWLoss - the level to set stop loss in the profit area, in points.
- LevelProfit - the number of profit points that the position must pass in order for the breakeven function to modify the stop loss.
- SetMinStops - automatically normalizes all parameters in points to the lowest stop level allowed on the server.
- Magic - the magic number of the EA's pending orders.
- Slippage - maximum allowable price slippage in points when opening and closing positions.
- MarketWatch - allows opening positions with the stop loss/take profit on accounts with the MARKET execution. First a position is opened; then, after a successful opening, the stop loss and take profit levels are modified.
- If the SPECIFID_Symbol_Monitoring parameter is not set and SymbolMonitoring = SPECIFID_SYMBOLs, then the EA monitors the currency pair it is attached to.
- Changed the conditions for closing Safety positions, if they are more profitable.
Close_One_if_Safety_Closed_In_Profit - close the original position if the SafetyLock position was closed with profit covering the current loss of the original position;
Close_One_if_Safety_Closed_In_Profit_Dollars - profit in USD to cover the original position;
Close_One_if_Safety_More_profitable - close the original position if the profitable SafetyLock position covers the current loss of the original position;
Close_One_if_Safety_More_profitable_Dollars - profit in USD to cover the original position;
Fixed an error than caused repeated modification of stop loss/take profit of the original position.
Updated the timer function. In case the timer does not start, the EA operates based on ticks.
SPECIFID_Symbol_Monitoring - added the ability to create a comma-separated list of symbols to be monitored.
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;