# The Clopwin Reversal Pattern — Detecting Quick Market Reversals.

# Coding the TD Clopwinlop Pattern and Analyzing its Predictability.

Sofienne Kaabar

Pattern recognition is the search and identification of recurring patterns with approximately similar outcomes. This means that when we manage to find a pattern, we have an expected outcome that we want to see and act on through our trading.

For example, a head and shoulders pattern is a classic technical pattern that signals an imminent trend reversal. The literature differs on the predictive ability of this famous configuration. In this article, we will discuss the TD Clopwin another timing and reversal pattern presented by Tom Demark.

If you are also interested in more technical indicators and using Python to create strategies, then my latest book may interest you:

**Coding the TD Clopwin Pattern**

Tom Demark, the renowned famous technical analyst has created many indicators and patterns. Among his many discoveries, he came up with a few short-term patterns, among them is a pattern called Clopwin.

Tom has developed these patterns to find short-term tops and bottoms. Any trader or even a receiver of such information would be excited knowing about this, but with hindsight and confirmation bias, the person seeing this, will test the patterns on the chart and *focus on the ones that work while disregarding the ones that do not*.

The only way to remedy this problem is by developing a systematic trading strategy based on these patterns, and that is precisely what we are going to do.

Requirements for a TD Clopwin Buy entry:

**The open and close of the current price bar must be contained within the open and close range of the previous price bar.****The close of the current price bar must be above the close of the prior price bar.**

Requirements for a TD Clopwin Sell short entry:

**The open and close of the current price bar must be contained within the open and close range of the previous price bar.****The close of the current price bar must be below the close of the prior price bar.**

To code this pattern, we need to define the primal manipulation functions first:

# The function to add a certain number of columns

def adder(Data, times):

for i in range(1, times + 1):

z = np.zeros((len(Data), 1), dtype = float)

Data = np.append(Data, z, axis = 1) return Data# The function to deleter a certain number of columns

def deleter(Data, index, times):

for i in range(1, times + 1):

Data = np.delete(Data, index, axis = 1) return Data# The function to delete a certain number of rows from the beginning

def jump(Data, jump):

Data = Data[jump:, ]

return Data

Assuming we have an OHLC array, we can define and use the scanner below that will look for the pattern and input 1 in case of a bullish Clopwin or input -1 in case of a bearish Clopwin. We will slightly modify the formula so that the idea of “contained within the range” incorporates the highs and lows. This way, the first condition is truly realized.

def td_clopwin(Data):

# Adding columns

Data = adder(Data, 20)

# Bullish signal

for i in range(len(Data)):

if Data[i, 1] < Data[i - 1, 1] and Data[i, 2] > Data[i - 1, 2] and Data[i, 3] > Data[i - 2, 3]:

Data[i, 6] = 1

# Bearish signal

for i in range(len(Data)):

if Data[i, 1] < Data[i - 1, 1] and Data[i, 2] > Data[i - 1, 2] and Data[i, 3] < Data[i - 2, 3]:

Data[i, 7] = -1

return Data

If you are interested in seeing more technical indicators and back-test, feel free to check out the below article:

**Back-testing the Pattern With no Risk Management**

The pattern will be back-tested in three ways. The first which is covered in this section, does not use any risk management. It opens and closes positions on closing prices and upon the next signal.

The second way is to use the optimal 2.0 risk-reward ratio which is simply setting the stop at half the distance from the entry compared to the distance of the profit level from the entry. Finally, the third way will use a suboptimal risk-reward ratio of 0.20. This means that we will target one fifth the stop we set.

The below are the conditions of the back-test:

**The time frame is hourly since 2010 using a 0.2 pip spread in order to simulate an institutional algorithm.****Opening of the position is based on a signal and its exit is based on finding another signal whether the same or a contrarian one.**

It looks like a free fall for any algorithm that uses this pattern. This is music to the ears of brokers who are looking to trade against you.

If you are interested by market sentiment and how to model the sentiment of institutional traders, feel free to have a look at the below article:

**Back-testing the Pattern With 2:1 Risk-Reward Ratio**

Intuitively, we need to risk less than we expect to gain and therefore by setting a theoretical 2.0 risk-reward ratio, we are respecting this risk management technique. The way we theoretically set this ratio is by using an indicator called the Average True Range which will be covered in a later section below.

The below are the conditions of the back-test:

**The time frame is hourly since 2010 using a 0.2 pip spread in order to simulate an institutional algorithm.****Opening of the position is based on a signal and its exit is based on finding another signal whether the same or a contrarian one.****Stops are triggered when the current quote hits 1x the value of the Average True Range at entry.****Profit orders are triggered when the current quote hits 2x the value of the Average True Range at entry.**

The strategy is still overall extremely painful to look at.

**Back-testing the Pattern With 1:5 Risk-Reward Ratio**

In parallel, a sub-optimal risk-reward ratio is where you risk more than what you expect to gain. In the long-term, this is assumed to be a losing strategy but it all depends on the hit ratio and the frequency of signals.

The below are the conditions of the back-test:

**The time frame is hourly since 2010 using a 0.2 pip spread in order to simulate an institutional algorithm.****Opening of the position is based on a signal and its exit is based on finding another signal whether the same or a contrarian one.****Stops are triggered when the current quote hits 5x the value of the Average True Range at entry.****Profit orders are triggered when the current quote hits 1x the value of the Average True Range at entry.**

Even though the last technique works better than the previous two, the strategy still underwhelms. The key point from this study is that theoretical patterns are not holy grail and should not be used without personally making sure they work.

**A Word on Risk Management**

When I say I use ATR-based risk management system (Average True Range), it means that the algorithm will do the following steps with regards to the position it takes.

**A long (Buy) position:**

- The algorithm initiates a buy order after a signal has been generated following a certain strategy.
- Then, the algorithm will monitor the ticks and whenever the high equals a certain constant multiplied by ATR value at the time of the trade inception, an exit (at profit) order is initiated. Simultaneously, if a low equals a certain constant multiplied by ATR value at the time of the trade inception is seen, an exit (at loss) is initiated. The exit encountered first is naturally the taken event.

**A short (Sell) position:**

- The algorithm initiates a short sell order after a signal has been generated following a certain strategy.
- Then, the algorithm will monitor the ticks and whenever the low equals a certain constant multiplied by ATR value at the time of the trade inception, an exit (at profit) order is initiated. Simultaneously, if a high equals a certain constant multiplied by ATR value at the time of the trade inception is seen, an exit (at loss) is initiated. The exit encountered first is naturally the taken event.

Take a look at the latest value on the ATR. It is around 0.0014 (14 pips). If we initiate a buy order following a simple 2.00 risk-reward ratio (risking half of what we expect to gain), we can place an order this way:

**Buy at current market price.****Take profit at current market price + (2 x 14 pips).****Stop the position at current market price — (1 x 14 pips).**

The code I use for the Average True Range indicator is as follows:

def ema(Data, alpha, lookback, what, where):

# alpha is the smoothing factor# window is the lookback period# what is the column that needs to have its average calculated# where is where to put the exponential moving average

alpha = alpha / (lookback + 1.0)

beta = 1 - alpha

# First value is a simple SMA

Data = ma(Data, lookback, what, where)

# Calculating first EMA

Data[lookback + 1, where] = (Data[lookback + 1, what] * alpha) + (Data[lookback, where] * beta)# Calculating the rest of EMA

for i in range(lookback + 2, len(Data)):

try:

Data[i, where] = (Data[i, what] * alpha) + (Data[i - 1, where] * beta)

except IndexError:

pass

return Datadef atr(Data, lookback, high, low, close, where):

# Adding the required columns

Data = adder(Data, 2)

# True Range Calculation

for i in range(len(Data)):

try:

Data[i, where] = max(Data[i, high] - Data[i, low],

abs(Data[i, high] - Data[i - 1, close]),

abs(Data[i, low] - Data[i - 1, close]))

except ValueError:

pass

Data[0, where] = 0

# Average True Range Calculation

Data = ema(Data, 2, lookback, where, where + 1)

# Cleaning

Data = deleter(Data, where, 1)

Data = jump(Data, lookback) return Data

# Conclusion & Important Disclaimer

If you regularly follow my articles, you will find that many of the indicators I develop or optimize have a high hit ratio and on average are profitable. This is mostly due to the** risk management method** I use. I **never **guarantee a return **nor** superior skill whatsoever. I am merely in the business of back-testing all the trading strategies out there for the sole goal of demystifying and weeding out the bad apples out there. As for the indicators that I develop, I constantly use them in my personal trading. Hence, I have no motive to publish biased research. My goal is to share back what I have learnt from the online community.

Remember to always do your back-tests. Even though I supply the indicator’s function (as opposed to just brag about it and say it is the holy grail and its function is a secret), you should always believe that other people are **wrong**. My indicators and style of trading work for me but maybe not for you.

I should point out a few things about my back-tests and articles:

**The spread I use is based on institutional quotes of a small pip fraction. Generally, retail traders are given a whopping spread of 0.80–3.00 pips per trade. This is huge and unfair to them. I back-test 0.2–0.5 spread. However, most of the “profitable” strategies that use the hourly time frame still work with 1 pip spread. For the ones that use M15 or M5 time frames, they cannot be profitable with a spread of 1 pip.****The holding period calculation I use is close-to-close in case there is no risk management process.****Some of the back-tests I provide are losers and they are published either to demystify a trading myth or to present interesting functions to be coded by readers.****Finally, I am a firm believer of not spoon-feeding. I have learnt by doing and not by copying. You should get the idea, the function, the intuition, the conditions of the strategy, and then elaborate (an even better) one yourself so that you back-test it and improve it before deciding to take it live or to eliminate it. That way you can share with me your better strategy and we will get rich together.**

To sum up, are the strategies I provide realistic? ** Yes**, but only by optimizing the environment (robust algorithm, low costs, honest broker, proper risk management, and order management). Are the strategies provided only for the sole use of trading?

**No**, it is to stimulate brainstorming and getting more trading ideas as we are**all sick of hearing about an oversold RSI as a reason to go short or a resistance being surpassed as a reason to go long. I am trying to introduce a new field called Objective Technical Analysis where we use hard data to judge our techniques rather than rely on outdated classical methods.**Upvote

Sofienne Kaabar

FX Trader | Author of the Book of The Book of Back-Tests

Related Articles