How to Create a Simple Reversal Trading Strategy
Creating a Trading Strategy Based on Patterns and Moving Averages
This article presents a simple reversal strategy based on a few simple technical tool. The main aim is to present a basic framework from where a more complex strategy is built.
For a detailed and thorough collection of trend following trading strategies, you can check out my book. The book features a huge number of classic and modern techniques as it dwelves into the realm of technical analysis with different trading strategies. The book comes with its own GitHub.
Trend Following Strategies in Python: How to Use Indicators to Follow the Trend.
Amazon.com: Trend Following Strategies in Python: How to Use Indicators to Follow the Trend.: 9798756939620: Kaabar…amzn.to
The Components of the Strategy
The strategy has two components, a pattern and a moving average. The two are used together as brothers in arms where the pattern delivers the signal and the moving average confirms it. This strategy is but a simple example of what you can do to combine technical indicators and tools together. What is the pattern?
The Kangaroo Tail pattern (as presented by Alex Nekritin and Walter Peters) is a one-candlestick reversal configuration that has roots in classic candlestick patterns (namely the hammer and Doji patterns), therefore, it may resemble them but with a few extra conditions to filter false signals.
The bullish Kangaroo Tail is composed of a very long wick where the open and close price are in the upper two thirds of the candle’s range (the high minus the low). Similarly, it must be in a down trend with a range that is superior to the prior candlesticks (to avoid what is known as a runaway).
The bearish Kangaroo Tail is composed of a very long wick where the open and close price are in the lower two thirds of the candle’s range (the high minus the low). Similarly, it must be in an up trend with a range that is superior to the prior candlesticks (to avoid what is known as a runaway).
As for the moving average, we will use a 200-period moving average to understand the market regime (bullish or bearish).
Coding the Strategy in TradingView
It’s time to code the strategy which is easily done in TradingView. The conditions are as follows:
A long signal is generated whenever a bullish Kangaroo Tail pattern is detected while the market is above the 200-period simple moving average.
A short signal is generated whenever a bearish Kangaroo Tail pattern is detected while the market is below the 200-period simple moving average.
The code of the strategy in Pine Script is as follows:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
indicator("Simple Reversal Strategy", overlay = true)
look_to_the_left = 200
candle_range = high - low
two_third_candle_range = candle_range * 0.66
bullish_kangaroo_tail = close > (two_third_candle_range + low) and open > (two_third_candle_range + low) and close > low[1] and close < high[1] and open > low[1] and open < high[1] and close < close[look_to_the_left] and candle_range > candle_range[1] and candle_range > candle_range[2] and candle_range > candle_range[3] and close[1] < open[2] and low <= ta.lowest(low, 13) and close > ta.sma(close, 200)
bearish_kangaroo_tail = close < (high - two_third_candle_range) and open < (high - two_third_candle_range) and close > low[1] and close < high[1] and open > low[1] and open < high[1] and close > close[look_to_the_left] and candle_range > candle_range[1] and candle_range > candle_range[2] and candle_range > candle_range[3] and close[1] > open[1] and high >= ta.lowest(high, 13) and close < ta.sma(close, 200)
plotshape(bullish_kangaroo_tail, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small)
plotshape(bearish_kangaroo_tail, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
plot(ta.sma(close, 200))
The following chart shows more signals from the strategy:
The following chart shows more signals from the strategy:
It is of course not a perfect strategy and many false signals may occur like in any other strategy in the world.
Summary
To sum up, what I am trying to do is to simply contribute to the world of objective technical analysis which is promoting more transparent techniques and strategies that need to be back-tested before being implemented. This way, technical analysis will get rid of the bad reputation of being subjective and scientifically unfounded.
I recommend you always follow the the below steps whenever you come across a trading technique or strategy:
Have a critical mindset and get rid of any emotions.
Back-test it using real life simulation and conditions.
If you find potential, try optimizing it and running a forward test.
Always include transaction costs and any slippage simulation in your tests.
Always include risk management and position sizing in your tests.
Finally, even after making sure of the above, stay careful and monitor the strategy because market dynamics may shift and make the strategy unprofitable.