This is a multi-asset expert adviser based on martingale trading strategy. Its original idea is taken from another expert adviser - ExpMartin
available for MT4.
Warning. Martingale is easy yet very dangerous strategy. Evaluate your risks carefully.
The strategy is to open reversal trades with increased lots after every loss, until a profitable trade occured or a maximal number of
reversals achieved. In both cases next trade will start with initial lot.
In comparison to the original one, this expert adviser demonstrates several points:
- conversion from MT4 to MT5 (MT4Orders and other header files are used,
please find all dependencies attached);
- conversion from functional
programming to OOP
paradigm, which in essence makes it possible to fulfill the next objective:
- adaptation from single-symbol to multi-symbol processing;
- source code refactoring for easier reading and support;
Also some bugs were fixed.
The program can still be improved in many aspects, for example, operation by timer, volatility analysis, etc. are left out of consideration.
Specific symbol settings - used for step by step optimization on every work symbol (should be selected as current chart symbol).
- UseTime - enable/disable new trades opening according to the range of hours [HourStart..HourEnd];
- HourStart - starting hour of the range when new trades are allowed; takes effect if only UseTime is true;
- HourEnd - ending hour of the range when new trades are allowed; takes effect if only UseTime is true;
- Lots - initial lot size;
- Factor - multiplication factor for increased lots;
- Limit - maximal number of multiplications, if reached - initial lot is used;
- StopLoss - distance to stoploss in points (no automatic pip adjustement);
- TakeProfit - distance to takeprofit in points (no automatic pip adjustement);
- StartType - trade type for starting order: o - buy, 1 - sell;
Common settings - used for trading.
- Magic - expert id;
- SkipBadTime - an option to wait predefined period of time after trading errors (such as "not enough money", "lost connection" etc);
- WorkSymbols - a string of work symbols and their specific settings, which should be selected after separate optimizations per every symbol; the
settings for symbols are separated by semicolon; the format is "name±lots*factor^limit(sl,tp)[start,stop];...", for
example "EURUSD+0.01*2.0^7(500,500)[2,22];AUDJPY+0.01*2.0^5(500,500)[1,21]" -- to trade EURUSD and AUDJPY starting with
buying (the plus sign) of 0.01 lots, then multiplied by 2 on losses up to 7 or 5 times correspondingly, stoploss and takeprofit are all 500
points, trading window differs by 1 hour;
- Trail - a mode how to treat stop orders: none - fixed level stoploss (no trailing), break-even - trail after profit equal to stoploss size in
points, straight - trail from very beginning (may end up with a loss up to the stoploss size in points, but not larger than that);
When used with multi-currency settings, it's advisable to place the expert to a chart with most liquid symbol (where ticks arrive most
frequently and trading sessions are continuous), for example EURUSD. Alternatively, one can replace OnTick event handler with OnTimer
and start a timer in OnInit.
MultiMartin trade performance on EURUSD for 3 years 2016-2019
MultiMartin trade performance on EURUSD,AUDJPY,GBPCHF for 2019