Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

Experts

MultiMartin - expert for MetaTrader 5

Stanislav Korotky

Views:
3734
Rating:
votes: 15
Published:
2019.12.05 22:13
\MQL5\Include\MT4Bridge\
MT4Mode.mqh (0.72 KB)view
MT4Time.mqh (1.59 KB)view
MT4Orders.mqh (88.65 KB)view
MT4Account.mqh (1.55 KB)view
MultiMartin.mq5 (18.59 KB)view

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.

MultiMartin trading 3 symbols in MT5 tester in visual mode

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.


Input parameters

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.


Example reports

MultiMartin trade performance on EURUSD for 3 years 2016-2019

MultiMartin trade performance on EURUSD for 3 years 2016-2019

MultiMartin trade performance on EURUSD,AUDJPY,GBPCHF for 2019

MultiMartin trade performance on EURUSD,AUDJPY,GBPCHF for 2019


    Scalp All Scalp All

    This script opens random position at market price on all symbols having spread below specified value.

    BitMEX Trading API Header files BitMEX Trading API Header files

    BitMEX Trading API Header files and example codes to trade on BitMEX exchange.

    BPNN MQL Predictor Demo with library BPNN MQL Predictor Demo with library

    This is a demo indicator with BPNN neural network library ported from C++ to MQL.

    WmiFor 3.5 for MT5 (with DTW engine) WmiFor 3.5 for MT5 (with DTW engine)

    This indicator predicts future price movements by searching for similar candle patterns in the rate history.