Automatic position management in Metatrader 4
Author: pavlus777
At first I wanted to post a universal expert advisor manager with many functions, but while testing it in practice, I noticed that it does not always perform the required actions when the conditions are met. Therefore I decided to share what I use myself: a set of expert advisors, each of which performs only specific functions, but does so clearly and without errors. After all, most often an ordinary user needs only a few options that are specifically useful to him.
Note 1: a description of the settings for each expert advisor is included in the archive.
Note 2: for dealing centers with 5-digit quotes, add 0 to the settings for the number of points.
Note 3: the time in the expert advisors is set according to the time in the terminal.
List of experts
e-CloseByLossOrProfit - The expert advisor closes all positions when the specified overall account loss or profit level in the deposit currency is reached. In addition, this expert advisor can also delete pending orders.
e-CloseByPercentProfit - The expert advisor closes all positions when the overall account profit, expressed as a percentage of the current balance, is reached, or when the overall account loss increases above a specified percentage relative to the account balance. In addition, this expert advisor can also delete all orders and close the terminal so that after fixing the profit or loss, no other expert advisor can trade anymore.
e-CloseByProfit - The expert advisor closes all positions when they reach a specified overall profit or loss level in points. When calculating the profit for each open position, the expert advisor takes into account only the difference between the position's opening price and the current price. Lot sizes do not affect the profit calculation.
e-CloseByProfitPosInCurrency - The expert advisor closes only those positions whose profit in the deposit currency has exceeded a certain specified value.
e-CloseOnTime - Want to close all positions at a certain time? This expert advisor will help you. This is especially convenient when you need to step away or while sleeping.
e-MoveSLTPbyMouse - The expert advisor is intended for moving the StopLoss and TakeProfit price levels of open positions with the mouse. Working with this expert advisor assumes manual opening of positions and manual initial setting of the StopLoss and TakeProfit price levels. Then, for each open position, the expert advisor creates two horizontal lines rigidly tied to the StopLoss and TakeProfit price levels. After creating these lines, the expert advisor begins to monitor their position on the chart. If you move some line with the mouse, the expert advisor immediately changes the price level to which the moved line is attached accordingly. When positions are closed and when the expert advisor is removed from the chart, it deletes its own lines by itself. If any of the price levels is not set, then the corresponding line will not be placed by the expert advisor.
e-MovingInWL - The expert advisor is intended for moving the stop of open positions to breakeven when they reach a certain specified profit level. If the parameter ShowComment=True, then the expert advisor will display the current price value and the stop value for each position (the price level and the value in points).
e-MovingInWL2 - The expert advisor is intended for moving the stop of open positions to breakeven when they reach a certain specified profit level. The main difference between expert advisor e-MovingInWL2 and its older brother e-MovingInWL is the presence of two additional parameters: AllSymbols and Magic, which make it possible to choose the monitored positions more flexibly.
e-MSound - is intended for tracking the movement of the instrument. Tracking is carried out in two directions (up/down) and over two distances, the specific values of which are configured in the parameters. As soon as the instrument passes the tracked distance, a sound signal is emitted. This is very convenient for receiving information that the instrument has moved, for example, 30 points up or down.
e-News-Lucky$ - At the appointed time, the expert advisor places BuyStop and SellStop stop orders. The distance for placing orders from the current market prices is configurable. If at the opening of a new bar no order has been triggered, the expert advisor modifies them. It moves them so that they are again at the required distance from the market. Thus, the current timeframe determines the frequency of modifying untriggered orders. Need it every 5 minutes, put the expert advisor on M5. Need it every hour, put it on H1. When one order is triggered, the other is deleted. The position is closed either by stop/take or at the set time.
e-OCO - The One Cancel Others expert advisor: one cancels the others. Triggering one order leads to the cancellation of other orders. The expert advisor monitors the appearance of any position (operation OP_BUY or OP_SELL) in the terminal. A position can appear either after a market entry or after a pending order is triggered. As soon as a position appears, the expert advisor immediately deletes all orders (operations OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT and OP_SELLSTOP). The expert advisor "sees" orders and positions only for the current symbol. It ignores orders and positions of another symbol.
e-OpenByTime - Your strategy and your preliminary analysis of the market situation suggest that you should make a trade at a specific time. And if such entries are infrequent, then it would be especially unfortunate to miss any of them because of some silly thing, like a traffic jam or any other physical inability to be near the computer. Expert advisor e-OpenByTime will help you. Put it on any number of instruments and on any timeframes. For each instance, set your own required trigger time in the TimeTrade parameter, and use the Sell parameter to set the trade direction. And be sure that if the absence of communication with the trading server does not interfere with the expert advisor, then it will definitely open a position. The time interval during which the expert advisor will try to open a position is limited by the Duration parameter.
e-ScreenShot - At the beginning of each bar, it takes a screenshot of the current chart. For example, if you put the expert advisor on M5, screenshots will be taken every 5 minutes. If you have indicators that you suspect of peeking, wiping, and other "tricks," then this expert advisor will help you catch the trickster without spending too much time on the procedure. Just put the indicator on the desired chart, attach our e-ScreenShot expert advisor to the same chart, and after some time study the screenshots in the folder ..\experts\files\.
e-SOTrailing - This expert advisor is intended for those who catch reversals with stop orders. In this case, the whole trading tactic comes down to placing stop orders at some distance from the market and moving them following the price. An important point: the orders are pulled toward the price, that is, they move only if the price has moved away from the orders. The orders do not run away from the price. This is exactly what expert advisor e-SOTrailing does: it trails stop orders.
e-SoundWorkOrder - This expert advisor will signal to you when a pending order is triggered. The expert advisor should be installed on only one chart, and it will monitor all your orders on all instruments. As soon as some order is triggered, the expert advisor will immediately give a sound signal.
e-Trailing2 - Supports two types of trailing: simple (parameter TSProfitOnly=False), that is, immediately after opening a position, the stop is pulled up by the size of the trail, and profit trailing (parameter TSProfitOnly=True), in which the stops move only after the position's profit exceeds the size of the trail. The expert advisor can be attached either to just one chart of any kind (AllSymbols=True) or to several (AllSymbols=False).
e-VTrailingByProfit - The expert advisor is intended for virtual management by the simple trailing method of an aggregate trader position according to its total profit in the deposit currency. An aggregate position is understood as one or more positions in one or more trading instruments. It should be kept in mind that the expert advisor does not place real stops. The stop-profit level is kept "in mind." The expert advisor implements selection of positions by the name of the trading instrument, by the type of trading operation (Buy/Sell), and by the position identifier (MagicNumber).
Download
Important! Nuances of installation in new builds of Metatrader 4
Source#forex#expert advisors#download#metatrader 4
At first I wanted to post a universal expert advisor manager with many functions, but while testing it in practice, I noticed that it does not always perform the required actions when the conditions are met.