The idea of the Expert Advisor was mine. The code of the Expert Advisor is written by Sergey Diubakin.
This version the Expert Advisor was used for trading on a PAMM account. Due to the human factor (i.e. me) the net profit was 20%. The maximum profit that could be reached made 84% of the initial deposit.
Real trading period: from 23.02.2015 to 23.07.2015.
According to my observations, trading with this Expert Advisor requires a large deposit (15 000 - 20 000 minimum).
The Moving Average indicator values are used for trading. If the fast Moving Average line is above the slow Moving Average line, and the distance between these two lines is greater than specified, then a buy order is opened.
The opposite values of the indicators are used for opening a sell order. Order closing happens according to the Moving Average indicator values.
This EA also has additional plugin modules: the distance between the fast and the slow Moving Average lines, Take Profit, Stop Loss, Trailing Stop, the distance between orders (up and down), Take Profit averaging method, Trade time, Turn, the increase of the first main lot in case the previous one closed with loss.
The algorithm of the EA:
Expert Advisor Settings:
Fast MA — settings for the Moving Average indicator plugin: period, offset, МА method. The Moving Average included in the MetaTrader 4 terminal is used.
Slow MA — settings for the Moving Average indicator plugin: period, offset, МА method. The Moving Average included in the MetaTrader 4 terminal is used.
4.1. Initial lot
- LotConst_or_not — allows the user to choose whether to start trading from the very same lot or to recalculate the initial lot depending on the deposit change:
true — the first lot will be constant and equal to the value of Lots, specified below;
false — the first lot will dynamically change according to the change of the deposit and will depend on the RiskPercent parameter and the size of the deposit. Lots =AccountBalance() * (RiskPercent / 100.0) / 10000.0
- Lots — sets the initial lot for trading;
RiskPercent — sets the initial lot depending on the deposit.
4.2. Increase of the lot
- FirstLotMultiplicator — parameter which is responsible for the increase ratio of every following first main order in case the previous first main order closed with a loss (closed by Stop Loss, "by hand" or simply with a loss);
- First_LotSize — if the first main order reached a value specified in this line, then the EA places Take Profit on the level set in the following line (First_LotSize_TakeProfit), but not in point 5 of the EA settings;
- First_LotSize_TakeProfit — a "new" Take Profit level of the first main order, in case it reaches the size set in the First_LotSize line;
- First_MaxLotSize — the maximum value to which the EA will increase the first main order. If the size of the first main order to be placed is greater than the value specified in this line, then the EA places the first main order according to p.3.1. of the EA settings.
Settings of the distance between the Fast MA and the Slow MA
Profit in points — TP
Averaging method — Varyant — a variant of TakeProfit level averaging method (selectable between 1 or 2).
Stop in points — SL
The distance between orders (Step Up) — the distance (interval) between opened orders in the order grid, set along the "trend".
true — the Step Up module is activated (on),
false — the Step Up module is deactivated (off).
9.1. Trailing stop — movable Stop Loss level.true — the Trailing stop module is activated (on),
false — the Trailing stop module is deactivated (off).
Distance between orders (Step Down) — the distance (interval) between opened orders in the order grid, set against the "trend".
true — the Step Down module is activated (on),
false — the Step Down module is deactivated (off).
The identifier of the EA's orders — Magic (Magic Number) — the parameter helps EAs to recognize their orders when trading in one terminal.
Logo and data output — ShowTableOnTesting — the parameter allows to turn the table (earnings today, yesterday etc.) on and off: true - on, false - off.
Time frame — program code that determines which chart timeframe will be used by the EA for trading.
Trade time — module for opening the first main order at a specific time.
true — the Trade time module is activated (on),
false — the Trade time module is deactivated (off).
Turn — places limit orders according to Stop Loss level of the first main order in the opposite direction.
true — the Turn module is activated (on),
false — the Turn module is deactivated (off).
This version the Expert Advisor was used for trading on a PAMM account. Real trading period: from 23.02.2015 to 23.07.2015.
The maximum profit that could be reached made 84% of the initial deposit. However, because of myself, the net profit was only 20%. The reason was that I interfered with the EA's trading.
The EA test runs I conducted showed 5%, 10%, 15% net profit yield per month with the drawdown of no greater than 20% of the deposit.
P.S. The attached sets operated only on the account I traded on. Custom EA setting are required for each DC/broker and account (demo or real).
Do not get carried away with the optimization, because it does not always help and may disregard order placement speed at very rapid movements.
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/13617
This indicator downloads history of symbols which have open charts. It will no longer be necessary to wait for an update when switching timeframes.Buying and Selling at the Same Time
This EA implements a grid strategy by placing buy and sell orders at the same time.