Today we will review the script for the Meta Trader4 terminal, which aims to close the existing trader order at the current price and open the opposite order. For example, if you have a buy order, then after applying this script your order will close, change its direction, and open a new order for sale.
You can turn both the current currency pairs on which the script is installed, and in general all open orders in the market, filtering out the extra pairs by the magic number, or on the list of tickets from your list (the listing must be entered through a comma without gaps).
An additional feature is the function of multiplying the trading lot when changing direction. For example, your trading lot was 0.1, and you want to reduce the risks by setting a 0.7 multiplier, then a new order will open with a lot of 0.07. The risk can also be increased.
When you change direction, both Take Profit and Stop Loss are available separately from the old order, i.e. If the target of the TP at your order was 20 points down relative to the opening price when selling, then it will become 20 points up for purchases.
|OrderSymbols||choosing a currency pair on which to perform a reversal order: current or all pairs in the market|
|Order Magic Number||the magic number of the order that you want to close and which will be assigned to the new order. At -1, orders with any Magic Number will be closed, and a new order will be assigned a magic “1234” so that it can be distinguished from a manual order.|
|OrderTickets||list of tickets on which the coup will be performed. It is indicated through a comma without gaps. Useful function, when the market is a lot of orders for different trading pairs and you need to turn several. If the value is left empty, all tickets will be taken into account during the coup.|
|Choose Order Direction||Choosing a direction for an overturned order: buying, selling, or all.|
|Lot Multiplier||multiplier for the lot of the future order. With this setting, you can increase or reduce the value of the lot relative to the closing position.|
|Transfer Take Profit||transfer of the Take Profit of the closed order to a new one in the opposite direction.|
|Transfer Stop Loss||transfer of the Stop Loss closed order to a new one in the opposite direction.|
An example of how the script works:
Suppose we have a warrant for a pair of EURUSD open for purchase with a lot of 0.01, Take Profit at 20 points, and Stop Los at 50 points.
We want to open at the current market price sales with an increased lot 2 times, transferring only Take Profit of the existing position. Magik number we don’t need to specify, as well as ticket, because we have this only deal in the market for this pair. We run a script with such settings:
We see that:
- The existing 0.01 order closed at the current price;
- The opposite order with a lot of 0.02 was opened;
- There was a modification of the purpose of the order and he was exposed only TP.
- The script has completed its work.
As you can see, this is a very simple but at the same time useful tool for traders engaged in manual trading with a lot of open positions in the market.