StrategyQuant offers a support & resistance ranking indicator to help predict and detect breakouts. Let’s use it to program an automated 15-minute USDJPY strategy!
You can download the strategy below from the Free Strategies section.
If you’re a trend follower like me, the word ‘breakout’ is music to your ears.
An explosive breakout could signal the start of a major price trend.
If you trade manually, chart patterns like flags and triangles are often good predictors of upcoming breakouts.
Discerning chart patterns using a trading algorithm is rather challenging. Fortunately, we can circumvent this by using StrategyQuant’s support & resistance ranking (SR%) indicator.
What’s the Support & Resistance Ranking Indicator?
The SR% indicator is not available in MT4 by default; you can download it here.
The SR% calculates the percentage of time the current close falls within the high-low range of each candle in the lookback period.
Here’s a couple of examples to illustrate how it’s calculated. Let’s use a 5-bar lookback period for clarity.
The large bullish candle shows a breakout from a period of consolidation. This candle has a SR% of 0%, because its close lies outside the high-low range of all 5 candles in the lookback period.
At the other end of the spectrum, here we have a small candle that’s caught within a range. Its closing price is within the high-low range of all 5 candles before it, so its SR% is 100%.
Using the Support & Resistance Indicator With Breakouts
You want to look for a series of low SR% values.
If the SR% falls sharply, it likely indicates a breakout has occurred. Here’s an example with a 50-period SR%.
If the SR% falls gradually, prices have been closing near the boundaries of the current trading range. This increase in buying/selling pressure means a breakout could be imminent.
Ideally, you want to see these low SR% values after a long period of consolidation. These are often followed by explosive breakouts.
Programming a Breakout Strategy
Now that we know what to look out for, it’s time to convert our idea into an algorithm.
To exploit the increased buying/selling pressure, I will enter the market when the SR% ≤ 3% for the three most recent closes.
This can be programmed very easily in AlgoWizard:
- Basic Mode: The SR% will use the bar highs and lows to determine the trading range, as illustrated above. The alternative, ATR Mode, adds an ATR buffer to the trading range. The (high + ATR) and (low – ATR) for each bar are used for the upper and lower boundaries, respectively. This ATR mode gives a delayed but more reliable breakout signal.
- LookbackPeriod: The number of bars used to construct the trading range. I’ll use 80.
- ATRPeriod: ATR lookback period if you use the ATR mode. Not relevant in this case.
- Bar shift : A shift of 1 refers to the most recently completed bar.  refers to the bar before that, and so on. All three conditions are identical except for the bar shift.
- Threshold: Percentage of time the current close falls within the trading range. I’ll use 3% here. For an 80-bar lookback, this means a maximum of 2 closes within the range.
Note that entry conditions are identical on the long and short sides.
This strategy actually reminds me of the classic Donchian channel breakout, where you go long when price closes above the highest high over the lookback period.
The Turtles used Donchian breakouts to great success in the 1980s.
A key difference is that the Donchian breakout condition only involves the most recent bar, whereas I’m looking at the three most recent bars here.
This should help focus on breakouts that are sustainable, instead of ‘fakeouts’ that quickly revert to the consolidation range.
The Support & Resistance + CCI Combo
I often use two or more conceptually distinct indicators when programming entry signals.
Awaiting confluence from two or more indicator types generally improves signal reliability.
Since the SR% indicator uses price action, I’ll pair it with a seriously underrated momentum indicator: the Commodity Channel Index (CCI).
The CCI measures the current price relative to an average price over a given lookback period. I’ll use a lookback period of 80, similar to that of the SR%.
I consider the market bullish when the CCI exceeds 100, and bearish when the CCI falls below -100.
Long entries will have an additional CCI > 100 condition, while short entries will need CCI < -100.
Time-Based Entry Filters and Exits
The periodic fluctuations in trading volume tend to have a large impact on short-term strategies.
Since this breakout strategy trades on the 15-minute timeframe, I’ll only enter the market when trading volumes are high.
The London open – New York midday window is usually when volumes are highest. A time filter was configured in AlgoWizard to only allow entries within this window. Don’t forget to use your broker’s time zone!
Lastly, since short-term strategies are most vulnerable to weekend gaps, I’ll prevent entries on Friday, and close all existing trades at Friday 3pm New York time.
Using Stop Entries for Confirmation
I like to use stop entries for breakout strategies, where some price confirmation is needed before I enter the market.
The entry price is marginally worse, but the improvement in reliability is usually worth it.
For this strategy, buy stops will be placed at 1 ATR above the previous high. Sell stops will be placed 1 ATR below the previous low. Each stop entry will be valid for 3 bars.
With all the rules in place, here’s an example of a long entry.
Backtesting the Support & Resistance Strategy
At last, here’s the 10-year backtest on the USDJPY.
There are long periods of stagnation within the first 5 years. Can the strategy be improved?
I had a detailed look at the equity curve and toggled the overlays for maximum favourable excursion (MFE) and maximum adverse excursion (MAE).
The MFE is the trade’s maximum open profit over the duration of the trade, while the MAE is the maximum open loss.
Looking at the MFE plot above, there were numerous occasions where the strategy lost a large chunk of open profits. Perhaps there was a sharp trend reversal after an undesirable economic report.
Adding a profit target is a good way to minimize open profit giveback. Since this is a trend following strategy, I know I’ll need the occasional outsized win to make up for the relatively low win rate (<50%).
So I’ll add in a 300-pip profit target.
Here’s the new backtest.
Stagnation, return/drawdown and profit factor have all improved.
The 300-pip profit target may seem excessive, especially for a 15-minute strategy. It was only triggered 10 times over the 10-year backtest, but these outsized gains were enough to significantly improve overall results.
Were the Time Filter & CCI Entry Condition Effective?
I first removed the intraday time filter. This means the strategy can now enter the market any time of the day.
The win rate only drops from 46% to 44%, but overall risk-adjusted performance is far worse. I’m keeping this filter for sure!
If I also remove the CCI entry condition, the strategy becomes untradable.
I think seeking confluence from different indicators, while keeping each indicator’s conditions ‘loose’, is the best way to go.
The support & resistance ranking indicator provides a simple way to detect increases in buying/selling pressure.
This can help you jump onboard the next breakout at the earliest opportunity.
Since the SR% indicator uses price action only, it’s best to complement it with momentum or trend detection indicators.
StrategyQuant’s analysis features are great for progressively improving your strategy. In this case, the MFE feature revealed that the strategy would benefit from a profit target. I recommend making 1-2 changes at most. Excessive tweaking will lead to overfitting.
Feel free to download the SR% strategy in the Free Strategies section!