Having shortlisted a basket of markets to develop your strategy on, the next step is to determine your entry rules. Your strategy’s entry is arguably the most important element of your strategy. The exit has a significant impact on your bottom line, but it is the entry that determines your ability to accrue floating profits. Like the casinos’ edge in Vegas, a successful entry gives you the edge in trading.
Entry testing is the first step in the MT4 development workflow, and will be followed by exit and filter testing. Continuing from the Market Research section, this article will illustrate an approach to select a trend following entry for the hourly GBPJPY. Three conceptually different entries will be backtested and their risk-adjusted returns will be evaluated. In keeping with Occam’s razor, only the lookback period will be optimized for each entry.
2. MT4 Considerations
Almost all brokers offer MT4 at no cost, but developing strategies with MT4’s backtester is laborious and time-consuming. I offer the following suggestions to make your backtesting more efficient:
- You can run multiple backtests simultaneously by opening additional instances of MT4, but note that MT4 backtesting is CPU-intensive.
- As much as possible, use the ‘Open Prices Only’ test model. With this model, your strategy’s logic is evaluated only at the opening of each bar, and only OHLC prices from the closed bars will be used. If your strategy does not rely on accurate intrabar price modeling, your backtest results will still be reasonably accurate. More details of MT4’s various testing models can be found here.
- If your strategy requires many inputs, save these as a preset file, which you can load prior to future backtests.
3. Performance Metrics
A good performance metric should satisfy the following two conditions:
1. It compares return to risk
Risk management is often a central focus of successful trading. Drawdown is often used to quantify risk, and is defined as a peak-to-trough equity drop. Numerous measures of drawdown exist, the most common of which is the maximum drawdown obtained over the backtest period.
2. It is normalized
A normalized metric allows convenient comparison across different markets and strategies. Volatile markets are likely to produce larger profits and drawdowns.
An example of MT4’s optimizer report is shown below. The available options are somewhat limited. Let’s go through each of them:
Figure 1: A typical MT4 optimizer report
3.1. Net Profit
Net profit fails both of the above conditions. Although profit and drawdown usually have an inverse relationship, some estimate of the strategy’s historical drawdown is required for real-time performance evaluation. Backtests provide the benefit of hindsight. In live trading, you need to trade through the drawdowns to realize the profits.
3.2. Number of Trades
While not a performance metric per se, it is crucial for the statistical significance of your backtest. The more trades you have, the more reliable your backtest statistics will be. When selecting your trading timeframe and backtest period, the number of trades in your backtest should be a key consideration. Longer backtest periods are always favourable since they produce more trades and cover more market conditions.
I personally consider any backtest containing fewer than 300 trades to be highly suspicious.
3.3. Profit Factor
Profit factor is defined as the gross profits divided by gross losses. It is normalized and thus versatile, but it provides no information on drawdowns. The equity curves in Figure 2 below both have a profit factor of 1.6. The one above has a 10% drawdown, while the one below has a 26% drawdown.
Figure 2: Two equity curves with similar profit factors but different drawdowns, showing how profit factor is a weak predictor of risk
3.4. Expectancy
Expectancy, sometimes called the average trade, is net profit divided by the number of trades. It suffers from the same drawbacks as net profit.
Expectancy should comfortably cover slippage and transaction costs. A common development pitfall is to select short indicator lookback periods, leading to high trading frequency and a low expectancy. If your backtest expectancy is only 1-2 pips, any unexpected increase in trading costs will likely turn a profitable strategy into a consistent loser.
3.5. Drawdown ($) and Drawdown (%)
MT4’s backtest report displays the maximum drawdown, taking into account both closed-trade equity and floating profits/losses. If you have a $500 drawdown from your previously closed trades, and your open positions have another $500 loss, MT4 will take your total drawdown to be $1000.
The choice of whether to use $ or % drawdowns depends on the type of position sizing applied throughout your backtest. If you trade a fixed lot size, use $ drawdown. If any sort of position sizing scheme was applied, % drawdown will be more appropriate.
Alternative drawdown metrics, such as the average drawdown and the Ulcer Index, are discussed here.
None of the above MT4 metrics are sufficient when used in isolation. I will instead use the Net Profit ($) / Maximum Drawdown ($) ratio from here on out. Returns are compared to risk, and the ratio allows quick comparison across strategies/markets. You can create a customized performance metric by analyzing your MT4 reports in Excel.
4. Backtest Settings
The following settings will be applied for the entirety of the MT4 development workflow:
- Market, Timeframe: GBPJPY, H1
- Data Period: Jan 2015 – Dec 2019
- Backtest model: Open prices only
- Transaction costs: 2 pips/round turn
5. Entry Contenders
Technical indicators are the building blocks of most trading strategies. Although indicators typically lag behind price action, their ability to transform complicated price action into actionable numbers is invaluable to many retail traders. Today’s trading platforms usually come preloaded with a vast array of indicators, though I believe there is redundancy among many of them. I prefer to use traditional indicators that have stood the test of time.
Many successful trading strategies use several technical indicators in concert with one another to determine entries and exits. Tweaking or augmenting your indicator’s logic to suit your trading preferences is also recommended. Nevertheless, this article will focus on common out of the box indicators, which when combined with appropriate exits and filtering, can lead to a profitable trading solution.
5.1. Bollinger Bands
Quite possibly the most popular indicator in retail trading, Bollinger Bands are a volatility-based channel indicator consisting of a simple moving average with price bands plotted at a standard deviation multiple above and below it. By default, a 20-period lookback is used for the moving average, and 2 standard deviations are used for the bands. If prices were normally distributed, they would lie between the bands 95% of the time. In reality, due to occasional large price movements, this only happens about 85-90% of the time. The beauty of the Bollinger Bands lies in its adaptive nature; the slope of the moving average indicates trend direction, while the band width indicates market volatility. The expansion of the bands during periods of high volatility serves as an automatic filter, helping to minimize ‘whipsaw’ trades.
Bollinger Bands can be used to generate entries for both countertrend and trend following strategies. For the latter, a longer lookback period of 50-100 is typically used. If prices have sufficient momentum to penetrate either band, it stands to reason that a nascent trend may be developing. Figure 3 shows an hourly GBPJPY long trade triggered when price penetrated the upper band.
Figure 3: 80-period Bollinger Band entry on GBPJPY. The middle moving average was used as a trailing stop.
An alternative to the Bollinger Bands is the Keltner Channels. I do a comparison of these indicators here.
5.2. Donchian Channels
Developed by Richard Donchian and made famous by the Turtles in the 1980s, Donchian channels are formed by plotting the highest high and the lowest low over the lookback period. A middle line, computed as the average of the upper and lower lines, is sometimes plotted to indicate the ‘average’ price. The width of the channel is an indication of market volatility. Just like Bollinger Bands, penetration of the channel implies strong momentum and is a plausible entry point for a trend trade. Figure 4 shows a short on GBPJPY triggered by a lower penetration of the channel. Considering the longevity of this indicator’s success over a variety of markets, it probably deserves your consideration.
Figure 4: 50-period Donchian channel entry on GBPJPY. The middle of the channel was used as a trailing stop.
5.3. Commodity Channel Index
Developed by Donald Lambert in 1980 to identify cyclical turns in commodities, the CCI has since achieved popularity in stocks and currencies as well. The CCI measures the current price relative to an average price over the lookback period. Unlike Bollinger Bands and Donchian channels, the CCI uses typical price for its calculations. Typical price is the average of the high, low, and closing prices, and some believe it paints a more representative picture of prices than the closing price alone. The mathematical formula for the CCI can be found here.
Similar to other popular indicators like the RSI and Stochastic, the CCI is a measure of price momentum. However, it is not range-bound, and its high volatility often gives rise to ‘whipsaw’ trades. A smoothing function may be applied to the raw CCI value to alleviate this. Although more commonly used to indicate overbought or oversold conditions, the CCI can be used for trend confirmation too. The +100/-100 levels are usually the thresholds that indicate strong momentum in either direction. Figure 5 shows a short GBPJPY trade taken with an 80-period CCI, with a -100 CCI value used as the entry signal.
Figure 5: 80-period CCI entry on GBPJPY. A 0 CCI value used for the exit. Note the high volatility of CCI values despite the lengthy lookback.
Each of the three entries will be tested as part of a reversal strategy. Testing the entries in this bare-bones manner reveals the natural profile of the entry’s returns and risks. For example, compared to the CCI, you would expect the Donchian entry to have a lower trade frequency, higher win rate, and larger profit per trade. Entry rules will also be symmetrical for the long and short sides. Because you cannot predict the market bias, having symmetrical rules is usually the prudent option.
6. Entry Testing Results
Each of our three entries had its lookback period optimized from 10-100, in steps of 1. The net profit / maximum drawdown ratio (NP/DD) was plotted as a function of the lookback period. Figure 6 shows the optimization results.
Figure 6: Entry testing results with Bollinger Bands, Donchian channels, and CCI
A few observations:
- This is not your textbook hump-shaped optimization chart with a conspicuous high plateau. Unless you test over a large range of fairly similar markets, your chart will probably look somewhat messy like this.
- Short lookback periods of 25 and below lead to losing strategies for all three entries. In trend trading, short lookback periods cause many ‘whipsaw’ trades and are usually a recipe for disaster.
- For all entries, the optimal lookback period is at least 50.
The CCI entry seems to be the most promising, with the NP/DD peaks at about 55 and 85-period lookbacks. To confirm this, I computed the average NP/DD values across all the lookback periods for the three entries. CCI came in tops at 2.69, followed by Bollinger Bands at 2.30 and finally Donchian channels at 1.83.
Which lookback period should I use for the CCI entry? Looking at the two CCI peaks, the second one (pink box) is clearly more stable. I will pick a lookback period of 85, in the middle of this region. 288 trades were obtained over the 5-year backtest period, about one trade per week. A CCI(85) entry will thus be used for subsequent development of our trend strategy on the hourly GBPJPY.
One last note on entry testing: Do not proceed if majority of your optimizations show a loss. Good exits and filters may eventually make your strategy profitable, but you will always be swimming against the tide.
7. Conclusion
This article has demonstrated a practical method of selecting a profitable entry for your strategy. The shortcomings of MT4’s default performance metrics were first discussed; the net profit / maximum drawdown ratio will instead be used to evaluate risk-adjusted returns.
Three popular technical indicators (Bollinger Bands, Donchian channels, CCI) were used to generate entries for an hourly GBPJPY trend strategy. The best performer was an 85-period commodity channel index, which will be used for the remainder of our trend strategy development using MT4.
An alternative entry selection method, which charts the entry’s profitability as the trade progresses, is described here.
In the next section, various exits will be tested together with this entry, in hopes of improving our trading solution.
