With an abundance of technical indicators available, selecting your strategy’s entry conditions can be overwhelming. This post will illustrate a method to graphically compare the profitability of different entries.
Entry selection is arguably the most important component of strategy development. A profitable entry allows profits to accrue quickly, minimizing your time in the market and giving you more flexibility when developing your trade exits.
When discussing Entry Testing in the MT4 Development section, I demonstrated the use of simple reversal strategies to rank the profitability of a few common entries. Here I will illustrate an alternative method which charts your entry’s profitability as the trade progresses.
We will focus on common technical indicators that are readily available to retail traders. These indicators have stood the test of time and are preloaded in practically every available trading platform.
These entries will be used in a countertrend manner; in other words, buy the oversold and sell the overbought. I prefer to optimize only the lookback period for my entries; default values will be used for all other entry parameters.
1. Bollinger Bands
Quite possibly the most popular indicator among retail traders, Bollinger Bands consist of a middle moving average line enveloped by a pair of lines placed two standard deviations above/below the average. Long trades will be opened when the price closes below the lower standard deviation line, and vice versa for shorts.
2. Donchian Channels
Popularized by the famous Turtles experiment, Donchian channels envelop the highest high and lowest low over the lookback period. Like the Bollinger Bands, a penetration of the lower/upper line indicates a buy/sell signal.
3. Exponential Moving Averages
Finally, we will test the classic moving average crossover system. Two moving averages will be used here, with the fast moving average having a lookback period half that of the slow one. When the fast moving average crosses below the slow moving average, downside momentum is present, and a long trade will be entered.
Market and Timeframe
The 4-hour (H4) timeframe is especially popular among retail traders and will be the focus of our tests. We will test on three markets that typically exhibit countertrend behaviour on this timeframe — GBPCAD, GBPCHF, CADCHF. Entry performance will be averaged across these markets.
For each entry under consideration, a simple strategy consisting of the entry condition and a bar-based time exit will be programmed. This exit closes the trade after a certain numbers of bars has elapsed, after which subsequent entries may occur if the conditions are met. For example, for the Bollinger Bands entry, the pseudocode for our algorithm will be:
‘Buy when price closes below the lower Bollinger band
Exit the trade after exitbars bars have passed
Opposite for short trades’
Using this strategy, backtests will be run with the exitbars parameter being optimized from 1 to 100. The expectancy of each backtest will be used to gauge the profitability of the entry when the trade is held for the specified number of bars. In this way, we can analyze the entry’s performance as a function of the holding period.
Since we are comparing different entries, a similar lookback period of 80 bars will be used for each entry. Later on in the post, we will look at the effects of varying this entry lookback period.
Compared to weaker entries, strong entries should contain a probabilistic edge that is larger and more sustained. Nonetheless, with how efficient markets are, any edge is usually transient, and all entries will lose their profitability over time. The chart below illustrates this thought.
Entry Testing Results
The algorithms were programmed using AlgoWizard and backtests were performed with StrategyQuant. The entry comparison graph for a 80-bar lookback period is shown below.
Personally it comes as no surprise that the exponential moving average entry is the worst performer. Expectancies remain negative until after 50 bars in the trade. I have tested moving averages ad nauseam and find that they usually only work well for longer-term trend following strategies. I suspect ‘whipsaw’ entries are the main drawback of moving average crossover strategies.
The Bollinger Bands and Donchian channels perform much better, and there are some interesting differences between them. The Bollinger Bands have a higher rate of profit accumulation until a holding period of 70 bars, after which expectancies begin to plateau and fall. On the other hand, Donchian channels’ expectancies continue to increase sharply until they hit a narrow plateau at about 90 bars into the trade.
I believe both these entries provide excellent starting points for subsequent strategy development. If you can only pick one, and wish to minimize your time in the market, the Bollinger Bands should be a better choice. I have a slight preference for the Bollinger Bands because of the wider expectancy plateau in the 70-90 bar range. They also tend to generate more trades than Donchian channels.
Diversifying Your Entries
Since you’re automating your trading, why pick only one entry? Portfolio trading is a great way to exploit the advantages of both entries. Bollinger Bands and Donchian channels are conceptually different and tend to produce uncorrelated strategies. Trading both these entries will likely add diversification to your portfolio and thus smoothen your overall equity curve.
Trade Management Tips
Entry selection aside, the relationship between expectancy and holding period can help guide subsequent strategy development. For the Bollinger Bands case, the plateau and eventual fall in expectancy after 70 bars indicates that trades should be closed by that point. You may wish to include some sort of time-based exit in the final strategy, or tighten your stops at that point.
Also notice how the Bollinger Band’s expectancies tend to hover about the breakeven point until about 20 bars into the trade. It may be worthwhile to delay your market entry by a certain number of bars, or get better bang for your buck by entering on a limit order.
Lookback Period Effects
Suppose we select the Donchian channels for our entry. Let’s now repeat the above test, but with two lookback periods — 40 and 80 bars.
In theory, a longer lookback period means more information is used for the entry, giving a more reliable entry signal. I expect the 80-bar lookback to give higher expectancies across the board, but the results above show otherwise. Expectancies only begin to diverge after 70 bars into the trade. This method may not be optimal if you’re looking to select a lookback period for your entry. Optimizing the lookback period directly and plotting the strategy’s performance vs. the lookback period will likely yield more conclusive results. I demonstrate that approach when discussing Entry Testing under the MT4 Development section.
From the graph above, I’d prefer an 80-period lookback over the 40, owing to the far greater expectancies after 70 bars. Nonetheless, higher expectancies do not necessarily indicate a better trading solution. The 40-bar lookback will generate more trades than the 80, and this could result in an overall improvement in net profit.
Expectancy is an important metric when working with strategies that trade very frequently, often only capturing a few pips per trade. Short-term countertrend and scalping strategies often fall into this category. If you underestimate your transaction costs, or market conditions shift even slightly, a small expectancy may turn negative.
So there you have it, a simple graphical method to help you rank and select trade entries. Three basic entries were illustrated above, but you can also apply this method to complex entries containing multiple conditions. With a profitable entry, you swing the odds in your favour from the outset.
As a final note, evaluating strategy elements across multiple markets will likely lead to more robust solutions. The graphs above used the average results obtained from three markets, but I recommend testing on more markets if you have the time.
Great post! Just want to confirm with you that the graphs presented here don’t consider the floating losses right? Althoght the graphs show positive expectancy, they could once in the negative floating loss position (which might translate to negative expectancy result).
I was wondering if the current entries test is meaningful because typically we have two entry rules, or sometimes even up to three, in usual cases. In such scenarios, it becomes necessary to optimize these multiple entry rules simultaneously, along with determining the optimal number of bars to exit. Fortunately, there are optimization functions available in platforms like StrategyQuant and MT4 that can assist us in efficiently handling these multi-variable tasks. So I cannot find this method is generalized for strategy testing to find valid entries. Unless it is purely only for indicators studying (instead of strategies studying).