cm-RUL simple virtual lock
You may trade any strategies and EAs but there comes a time when your trading reaches a deadlock. At that time all dogmas and rules are violated and you don’t even know what to do next. You give up and wish to take a time-out but there are several thousand dollars at stake – it will hurt your feelings if you abandon them to their fate. Of course, you can simply set a locking order, go on vacation and settle the whole situation later in a calm atmosphere. However, you can also trust the EA to handle this and rest easy.
he EA-settler called “cm-RUL simple lock” was specifically developed for the situations where you don’t know anymore what you can do to save your account.
Let’s take this situation as an example.
We have 10 open Buy positions of 25 lots and price moves down. Drawdown has hit more than 50% of our deposit but we have another $1,000 of free margin on our account.
If we don’t do something in this situation, Margin Call will occur on our account and our deposit will be lost if the price keeps moving down further. We must set Sell locking order of 25 lots and remove Stop-Losses and Take-Profits of all open positions to avoid it. We don’t know where the price is going to move – this is why we will have a drawdown even if these positions close in profit by Stop-Losses and Take-Profits. After that, whenever the price goes, free margin level will not change (or change a little within the scope of swaps charged). We shouldn’t leave our deposit when it is like this. When the EA switches to trading in a locking mode, it will start to “settle” the situation. Let’s consider the process in more details.
Note that the button “Settle” must be pressed in order to run the EA!
We have 25 lots of Buy and 25 lots of Sell orders in total.
The EA-settler will look for the most distant Buy order and the most distant Sell order.
Assuming that the most distant Buy order size is 10 lots and that of the most distant Sell order is 0.01 lots.
The EA settings are as follows: size of “settling” lot (the lot size that the EA “bites off” a losing position) is 0.01 lots, lot multiplier is 1.5, step is 10 points, and MinProfit = 2 points.
Let’s consider the following market scenario: price moves up and averaging Sell positions of 0.01, 0.02, 0.03, 0.05, 0.08, 0.11, 0.17, 0.26, and 0.38 lots are opened gradually.
In this case, the price has to move for 90 points (It is rather rare for 4-digit charts and 50-point movements are more common; after that, a pullback occurs, etc. These data may differ depending on the financial instrument) without a pullback so that these 9 averaging positions can be opened. Notwithstanding the path the price has covered, the EA has opened positions in the total amount of just over 1 lot that has a negligible impact on the overall state of our account! Afterwards, the price moves down. At some point of time, all these 9 averaging Sell orders yield the profit which is larger than the loss incurred by the most distant (below the current price) Sell order (not the entire order but only by its part – 0.01 lots). MinProfit parameter (displayed as Point on the info panel) defines what the value that profit must exceed loss by is. Next, the EA closes the most distant Sell order and all averaging Sell orders in a total profit of about 2 points. The profit size is approximate since price might jump down (and our profit will be more than 2 points) or up (and our profit will be less than 2 points) while these 10 orders are being closed. If the price moves for more than 2 points up at this time, we will suffer a little loss. So, you may increase the minimum profit in the MinProfit parameter but to the extent so that the price can reach this profit level. Simply put, don’t be greedy and nickel-and-dime. The given parameter is customized individually for every currency pair and must not be less than spread value.
Now we have 25 lots of Buy and 24.99 lots of Sell positions.
Next, the price moves down, and the EA opens Buy positions of 0.01, 0.02, 0.03, 0.05, and 0.07 lots, following which it moves up again. When the total lot size of all these Buy positions exceeds 0.0001% of the most distant Buy position, i.e. 10 * 0.0001% = 0.01 lots, all the “settling” Buy positions and 0.01 lots of the most distant Buy position have been closed.
Now we have 24.99 lots of Buy and 24.99 lots of Sell positions. The EA has decreased the lot size by 0.01 lots on every side of the market and at that earned several points at every such close.
Next, the EA closes all the positions in profit according to the scheme described above. The process is certainly slow going, but we can accelerate it by increasing “settling” lot size or decreasing a step – however, in this case, we might have to replenish our deposit so that we have enough funds for opening “settling” lots. The “settling” lot size must be calculated in such a way so that the EA will have a sufficient amount of funds to open the most distant averaging orders allowing for the given step if the price moves in one direction without a pullback. As a rule, it opens no more than 8 positions but things can happen. We must take into account volatility of a currency pair, point value denominated in a currency and margin … Generally speaking, these parameters are individual for each broker and currency pair and should be selected experimentally in a Tester.
Therefore, if price makes not long pullbackless movements in the nearest future, our deposit will grow and “unload” itself from unnecessary lots; if the price makes a pullbackless movement, we should either need opening a “settling” lot and averaging or locking of orders from the scratch and launching the EA-settler with another magic number so that it can close its lots gradually but not immediately.
The EA has a few more useful parameters:
“SumProfit” – profit in deposit currency
The EA will close all open positions by their total profit specified in the “SumProfit” parameter. In this case, all positions will be closed on the principle of counter-closing, i.e. a position is closed by the opposite (locking) position. By doing so, we not only accelerate the process of closing but also save half of a spread. It is needed for an ordinary trading when: 1) you have “settled” the current situation entirely and just open positions manually or with the EA, or 2) the EA-settler has turned losses incurred by positions of some direction into solid profit and “unloaded” positions of the opposite direction to the extent that positions of both directions have yielded profit in total
We have 24.99 lots of Buy and 24.99 lots of Sell positions left in sum. Price has moved 50 points up and then 30 points down. Another 0.01 lots of Sell positions have been closed. The price has made these up and down movements a few times and covered the distance of 200-300 points that resulted in closing 5 lots of Sell positions. We have 24.99 lots of Buy and 19.99 lots of Sell positions. However, all our Buy positions show a large profit at the moment and can easily cover losses incurred by the Sell positions. So, if the total profit of all the positions is larger than the value specified in “SumProfit” parameter in terms of deposit currency, the EA will close all of them and thereby “unload” deposit for further trading and withdrawal of funds!
The EA provides for multi-level control over the closing of orders. First, the EA makes 10 attempts to close orders if a broker provides price requotes. Second, “settling” orders are closed first; if only they have been closed in profit which is enough, the EA will “bite off” parts of losing positions – it doesn’t enable broker to reduce account balance.
Note that you should press the button “auto lock” to activate the function “lock”!
The function is active only when price moves in a channel between the most distant Buy order (at the top) and the most distant Sell order (at the bottom) or price moves in the direction of negative misbalance (orders on both sides of the market differ in terms of their total volume in lots). As soon as the price moves beyond the channel or the balance of lots is restored, the function will be deactivated. By pressing the button “lock” the EA will analyze the market situation and compare the total trading volume of Buy and Sell positions. The EA will either open missing lots on the losing side of the market or close some winning lots on the winning side of the market in order to equate the volume of lots on both sides. At that, the difference between the lot volume must exceed the “settling” lot size. The pressed button “lock” turns green when the function “lock” is active and grey if the current misbalance is zero or price moves in the direction of misbalance (for example, if the price moves down and the total lot volume of Sell orders is larger than that of Buy orders, locking will be disabled).
1. We have 24.99 lots of Buy and 25 lots of Sell positions left. – The EA doesn’t place a locking order since the difference between the volume in lots is not larger than 0.01 lots.
2. We have 24 lots of Buy and 25 lots of Sell positions left. All the Sell positions are losing. – The EA opens 1 lot Buy position and equates the lot volume on both sides of the market. Now we have 25 lots of Buy and 25 lots of Sell positions.
2.We have 24 lots of Buy and 25 lots of Sell
positions left. 0.5 lot Sell position is winning. – The EA closes 0.5 lot Sell position and opens 0.5 lot Buy position. Now we have 24.5 lots of Buy and 24.5 lots of Sell positions.
We have 24 lots of Buy and 25 lots of Sell positions left. Sell position of more than 1 lot is winning. – The EA closes 1 lot Sell position. As a result, we have 24 lots of Buy and 24 lots of Sell positions.
By the way, the “Lock” function is not always useful. One really need it at the first stage (when orders of both directions are very different from each other in terms of their total volume in lots), but if price has moved through the levels of already locked positions and now it is far from them, sometimes it is better to disable the “Lock” function to prevent it from closing winning positions but let profits run; by doing so, all orders will be closed by their total profit in deposit currency.
You can launch the EA in a Tester and enable Visualization mode, enter the lot size like that on your real account and open Buy and Sell positions simultaneously. Next, press the button “Settle” on the info panel and monitor the process of trading. You can select all parameters during the process and then copy them on your real account.
The EA’s version “cm-RUL simple virtual lock” offers new features:
1) Limit on the maximum number of “settling” orders. The EA changes its magic number and locks all the orders from the start if the number above equals the specified value. Therefore, when the magic number changes, the EA sees all the “settling” orders as ordinary ones and lock them in the same way thereby reducing drawdown during a long pullbackless movement.
2) Lock trailing. Locking order is not placed immediately – it is opened on the principle of a crawling order: if price moves up, the EA will set a Buy locking order; if it goes down, the order will not be set. The opposite is true for a Sell locking order. At that, a locking order is placed on the principle of a stop-order but only with market execution, and control over the distance from price to virtual stop-order is exerted by the EA itself (virtual stop-order).
3) Averaging orders also work according to the principle of a crawling order: averaging position is not opened immediately at the current price – first, a virtual stop-order is set (see Aqua and Magenta lines on the chart). Afterwards, the virtual order crawls after price and triggers only when the price pulls back – thereby, it doesn’t let to open averaging orders against price movement.
If we set the distance to an order (it’s true both for averaging and locking orders) to 0, things will happen as if the previous version of the EA is used: a position (but not a virtual stop-order) will be opened immediately and at the current price. It is true for locking and averaging orders.
4) Moving the whole series of orders to breakeven was added. If price moves beyond the whole series of orders, for example, above all Buy positions, and at that the EA opens a virtual averaging Sell position, all the Buy positions will be moved to breakeven. In this case, the EA sets Stop-Loss at the most distant Buy order (at the top) price level plus the minimum profit. The opposite is true for Sell positions. You can disable the function by NoLoss parameter.
The EA’s parameters. (All basic parameters can be customized directly on the info panel – but not in the EA’s settings – and are updated after restart of the panel.)
================== “settling” functions
RU = true;// the button “Settle” is enabled by default
LevelRU = 10;// distance to an averaging order
Step = 10;// minimum step between “settling” orders
MinProfit = 2; – minimum profit in points by which all orders of a series are closed
Lot = 0.01;// “settling” order’s lot size set by default
K_Lot = 1.5; – “settling” lot multiplier
TimeSleep = 60;// time of delay before opening a “settling” order
AutoLock = true;// the button “lock” is enabled by default
LevelLock = 20;// distance to a locking order
NoLoss = true;// moving the whole series of orders to breakeven
SumProfit = 100.0; total profit in deposit currency by which all orders of a series are closed
AutoTrade = false;// automatic trading (if there are no open positions)
LOTTEST = 0.1;// lot size used for the EA testing or automatic trading
Max_Lot = 10.0; – maximum possible size of lot which can be opened by the EA (if it needs to open 25 lot locking position, and the value is set to 10, it will open three locking positions of 10, 10, and 5 lots)
Max_Orders = 10;// maximum number of “settling” orders
Slippage = 30;// slippage
Magic = 1212; – magic number of “settling” orders (it mustn’t coincide with other magic numbers)
Key = 4158266;// key required to start trading on a real account
The key to 1 trading account costs 50 USD. You can make a binding to all accounts opened on a specific user name. To do this, please contact the mail email@example.com or telegram: mqlcmillionCm-RUL Simple Virtual...