Expert Advisor Development On MT4 / MT5 For Automated Algorithmic Trading On EURUSD M1 Data
Expert Advisor Development On MT4 / MT5 For Automated Algorithmic Trading On EURUSD M1 Data
Expert Advisor Development on MT4 / MT5 for Automated Algorithmic Trading on EURUSD M1 Data
September, 2013
Special thanks to the MQL4.com and MQL5.com community for their insightful comments that have made this work
possible.
Abstract
This paper reports the performances of expert advisor (EA) strategies that are tested on the popular metatrader –
metatrader4 (MT4) and metatrader5 (MT5) – platforms. The results compare performances of USD1,000 and
USD10,000 initial capital accounts; for the test period of January 2013 to August 2013 on per minute (M1) data, the net
profit returns are 91.8% and 92.9% respectively, providing evidence that the trading strategies are robust for micro-
trading accounts. Further development work is to be performed for improvements in the absence of trades, reduction of
the average loss trade and maximal drawdown.
Introduction
From the perspective of the trader or fund manager, if one is to maximize profits or returns, a logical inference on the
average number of transactions per trading day is dependent on the number of opportunities that present themselves. It
is a frequent activity for traders to observe patterns of price movements and of selected technical indicators, such as
bollinger bands, average directional index (ADX), moving average convergence divergence (MACD), momentum (Lam et
al., 2007, 2012; Fabozzi et al., 2013) and others, so as to visually capture repeating trends. With the use of algorithms,
these repeating trends can be captured and tested with precision. While the reliance of fundamental analysis is critical
for traders, it is a task that works in tandem with trading algorithms or the black box. It is also implied that the focus on
technical analysis (Bai et al, 2009) to predict movements due to fundamentals is the objective of automated algorithmic
trading (Chan and Wong, 2012).
Over the past decade, the development of automated trading strategies have increasingly become mainstream in the
trading community on the MT4 and MT5 platforms. This study develops an expert advisor, which is the term for an
automated trading algorithm on the metatrader platforms, based on hundreds of trials and errors that utilize a suite of
some 30 plus technical indicators that are both common and customized. The ultimate choice of the input variables
(indicators and specifications) used in developing the expert advisor is proprietary and will not be revealed in this study.
For more information, please contact the authors.
Data Analysis
EURUSD data is obtained from the FXPro server and the back-test is performed using the strategy tester module in
metatrader. Long/Short positions are both allowed and there is the option of genetic optimization (Bai, et al., 2009) with
the following settings:
Optimized Parameters: Balance, Profit Factor, Expected Payoff, Maximal Drawdown, Drawdown Percent.
Optimization Limitation: Balance minimum, Profit maximum, Minimal margin level, Maximal drawdown, Consecutive loss,
Consecutive loss trades, Consecutive win, Consecutive win trades.
Copyright 2013 1
The algorithm settings include the following but not limited to: risk per trade, maximum total risk, maximum account risk,
stop loss pips, take profit pips, start hour, end hour, etc. Every tick data is used for analysis which is the most precise
method based on all available least timeframes to generate each tick. Spread levels are set at current which is the most
realistic method of approximation. A low spread level of less than 10 pips will improve test results while a spread level of
more than 30 pips can reduce test results. Spreads widen during high price volatility and as such, the success of trades
should reduce during higher spreads or higher price volatility. An important implication is that a successful expert advisor
with short-term intraday trades should be able to be successful during periods of lower spreads and price volatility as a
more efficient strategy.
Over the eight months under analysis, the estimated maximum price is approximately 1.363 while the minimum price is
1.278, offering 850 pips or 6.65% return. It is observed from the above price chart that potentially higher returns are
possible with an actively managed trading strategy or portfolio of strategies.
Test Results
The strategy tester results are reported below for two accounts with different initial capital sizes, namely USD1,000 and
USD10,000 accounts. Utilizing the same expert advisor and with the same conservative specifications, it is noted that the
results for both accounts are similar. There is evidence to state that the EA is specified sufficiently to cope with micro-
trading accounts of USD1,000. This implication is important as numerous forms of EA tested produce varying results with
different sized accounts.
It is critical to note the importance of the total trades transacted for both accounts – 566 for USD1,000 account and 574
for USD10,000 account. This implies that for the approximately 160 trading days, the average number of trades per day
is greater than 3.5 to generate the returns at a maximal drawdown of 20.2% (same for both accounts).
While the other statistics are similar for both accounts, notably more than 70% of successful long/short trades are
produced, it is noted that long transactions are more successful than short transactions, which highlight a potential
improvement focus for next efforts. It is also well noted that the average loss trade is about double the average profit
trade, while the largest loss trade is about 15% more than the largest profit trade.
Copyright 2013 2
Figure 1.2 – EURUSD Strategy Test (M1) for USD1,000 Account, Jan 2013 - Aug 2013
Figure 1.3 – EURUSD Strategy Test (M1) for USD10,000 Account, Jan 2013 - Aug 2013
Copyright 2013 3
JOURNAL
Leading Research in Risk Control for Sustainable Returns Finamatrix.com
_______________________________________________________________________________________________
In Figure 1.4, all the trades executed for the period under analysis is displayed and we note the peculiarity of two regions
where there are the absence of trades, specifically in the months of February and March of 2013. Upon scrutiny, the lack
of trading activity during that period was not due to insufficient capital, but rather the period did not trigger any form of
long/short trade by the EA. This is another area of consideration for further improvements.
Figure 1.4 – EURUSD Long/Short Trades of Expert Advisor, Jan 2013 - Aug 2013
Conclusion
Expert advisor development is at the forefront of quantitative trading for achieving precise risk control for the creation of
sustainable returns in the financial markets. The use of long/short transactions on foreign exchange or any investment
instrument with sufficient trading volume or market depth which allows long/short trades such as the stock index or
commodity futures markets are good examples for expert advisor development. The success of EA depends on a myriad
of factors that may be suitable for certain market conditions. This study has shown that EA success is possible for micro-
trading accounts which can benefit not only institutional investors, but also retail investors.
References
Bai Z, Liu H and Wong WK (2009) Enhancement of the Applicability of Markowitz's Portfolio Optimization by Utilizing
Random Matrix Theory, Mathematical Finance 19(4) 639-667.
Chan, LCWJ and Wong WK (2012) Automated Trading with Genetic-Algorithm Neural-Network Risk Cybernetics: An
Application on FX Markets. Finamatrix Journal, Feb 2012.
Fabozzi FJ, Fung CY, Lam K, Wong WK (2013) Market Overreaction and Underreaction: Tests of the Directional and
Magnitude Effects, Applied Financial Economics (forthcoming).
Lam K, Liu T and Wong WK (2012) A New Pseudo Bayesian Model with Implications to Financial Anomalies and
Investors’ Behaviors, Journal of Behavioral Finance 13(2) 93–107.
Lam VWS, Chong TTL and Wong WK (2007) Profitability of Intraday and Interday Momentum Strategies, Applied
Economic Letters, 14, 1103–1108.
Emerging-Managers.com
MQL5.com
Copyright 2013 4