# The Know Sure Thing Technical Indicator

### Presenting & Coding the Know Sure Thing Indicator

This article discusses a structured oscillator called the Know Sure Thing. It is mainly used in reversal trading strategies and to confirm the already established bias. We will also take a look on how to use it after coding it in Python.

I have released a new book called *“Contrarian Trading Strategies in Python”*. It features a lot of advanced contrarian indicators and strategies with a **GitHub **page dedicated to the continuously updated code. If you are interested, you could buy the PDF version directly through a PayPal payment of **9.99 EUR.**

Please include your email in the note before paying so that you receive it on the right address. Also, once you receive it, make sure to download it through google drive.

**Pay Kaabar using PayPal.Me***If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you…*www.paypal.com

### The Rate of Change Indicator

The rate of change of a security can be found by using the below formula:

It describes the evolution of the value over time. If the previous price of a security was $100 and is now $110, then the rate of change will be 10%. This means that the market price increased by 10% since the previous period.

The rate of change Indicator is an oscillator that uses the above formula on a rolling basis and for a specified lookback period. A lookback period of 3 means that we will calculate the rate of change between the current price and the price 3 periods ago. The below plot shows an example of a 10-period lookback.

Let us now see how we can use this simple indicator as a main ingredient in the Know Sure Thing cooking recipe.

Check out my weekly market sentiment report to understand the current positioning and to estimate the future direction of several major markets through complex and simple models working side by side. Find out more about the report through this link:

**Coalescence***A Weekly Report Covering FX & Equities Market Positioning Using Complex Models. Let me read it first This site requires…*coalescence.substack.com

### The Know Sure Thing Indicator

Developed by Martin Pring, the KST uses smoothed versions of the rate of change to interpret changes in momentum. It is an unbounded oscillator that resembles the MACD and uses four rate of change calculations with different lookback periods as illustrated below:

We then take a 10-period simple moving average on the first three ROC’s and a 15-period simple moving average on the last ROC. Finally, we use the following formula to calculate the Know Sure Thing:

We then calculate a signal line which is simply a 9-period moving average on the KST.

The figure above shows the KST in blue with the signal line in red. Notice how it oscillates over the zero line and crosses its signal line from time to time.

```
# The function to add a number of columns inside an array
def adder(Data, times):
for i in range(1, times + 1):
new_col = np.zeros((len(Data), 1), dtype = float)
Data = np.append(Data, new_col, axis = 1)
return Data
```

```
# The function to delete a number of columns starting from an index
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 number of rows from the beginning
def jump(Data, jump):
Data = Data[jump:, ]
return Data
```

```
# Example of adding 3 empty columns to an array
my_ohlc_array = adder(my_ohlc_array, 3)
```

```
# Example of deleting the 2 columns after the column indexed at 3
my_ohlc_array = deleter(my_ohlc_array, 3, 2)
```

```
# Example of deleting the first 20 rows
my_ohlc_array = jump(my_ohlc_array, 20)
```

`# Remember, OHLC is an abbreviation of Open, High, Low, and Close and it refers to the standard historical data file`

```
def ma(Data, lookback, close, where):
Data = adder(Data, 1)
for i in range(len(Data)):
try:
Data[i, where] = (Data[i - lookback + 1:i + 1, close].mean())
except IndexError:
pass
# Cleaning
Data = jump(Data, lookback)
return Data
```

`def know_sure_thing(Data, lookback1, lookback2, lookback3, lookback4, close, where):`

```
Data = adder(Data, 5)
# First ROC
for i in range(len(Data)):
Data[i, where] = ((Data[i, close] - Data[i - lookback1, close]) / Data[i - lookback1, close]) * 100
# Second ROC
for i in range(len(Data)):
Data[i, where + 1] = ((Data[i, close] - Data[i - lookback2, close]) / Data[i - lookback2, close]) * 100
# Third ROC
for i in range(len(Data)):
Data[i, where + 2] = ((Data[i, close] - Data[i - lookback3, close]) / Data[i - lookback3, close]) * 100
# Fourth ROC
for i in range(len(Data)):
Data[i, where + 3] = ((Data[i, close] - Data[i - lookback4, close]) / Data[i - lookback4, close]) * 100
```

```
# Smoothing
Data = ma(Data, lookback1, where, where + 4)
Data = ma(Data, lookback1, where + 1, where + 5)
Data = ma(Data, lookback1, where + 2, where + 6)
Data = ma(Data, lookback2, where + 3, where + 7)
```

```
# KST
Data[:, where + 8] = Data[:, where + 4] + \
(Data[:, where + 5] * 2) + \
(Data[:, where + 6] * 3) + \
(Data[:, where + 7] * 4)
# Signal line
Data = ma(Data, 9, where + 8, where + 9)
# Cleaning
Data = deleter(Data, where, 8)
return Data
```

Trading this indicator is based on simple crossover rules and are as follows:

**A long (Buy) whenever the KST line crosses over the KST signal line.****A short (Sell) whenever the KST line crosses under the KST signal line.**

```
def signal(Data, kst, kst_ma, buy, sell):
Data = adder(Data, 2)
for i in range(len(Data)):
if Data[i, kst] > Data[i, kst_ma] and Data[i - 1, kst] < Data[i - 1, kst_ma]:
Data[i, buy] = 1
```

```
elif Data[i, kst] < Data[i, kst_ma] and Data[i - 1, kst] > Data[i - 1, kst_ma]:
Data[i, sell] = -1
return Data
```

In general, the signals are a little late to the party and are not of high quality. The hit ratio and profitability metrics of this indicator are not impressive.

### 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.

For the paperback link of the book, you may use the following link:

**Contrarian Trading Strategies in Python***Amazon.com: Contrarian Trading Strategies in Python: 9798434008075: Kaabar, Sofien: Books*www.amazon.co