avatarSofien Kaabar, CFA

Summary

Tom Demark's Rate of Change (TD ROC) Indicator is a momentum-based contrarian trading tool, distinct from the traditional Rate of Change Indicator, and its implementation in Python is detailed in a new book by Sofien Kaabar, which also includes advanced contrarian strategies and continuously updated code on GitHub.

Abstract

The article introduces Tom Demark's Rate of Change Indicator, a unique trading tool that diverges from the standard Rate of Change Indicator by incorporating a different lookback period and closely resembling the Momentum Indicator. This contrarian indicator is part of the advanced trading strategies discussed in Sofien Kaabar's recent book, "Contrarian Trading Strategies in Python," which follows his previous successful publication, "Trend Following Strategies in Python." The book is accompanied by a GitHub repository with updated code for readers to explore and utilize. The TD ROC Indicator is explained with its formula and practical examples using EURUSD and USDCHF hourly data. Additionally, the article emphasizes the importance of objective technical analysis, encouraging traders to back-test and optimize strategies, include transaction costs and slippage in tests, and incorporate risk management and position sizing. The author also promotes Medium membership through a referral link and recommends Lumiwealth for educational courses on algorithmic trading, blockchain, and machine learning.

Opinions

  • The author, Sofien Kaabar, values the contribution of objective technical analysis and promotes transparent and back-tested trading strategies to enhance the credibility of technical analysis.
  • Kaabar suggests that traders should approach new trading techniques with a critical mindset, free of emotions, and rigorously test them under real-life conditions before implementation.
  • The article implies that continuous learning and adaptation are crucial in trading, as market dynamics can change and render previously profitable strategies ineffective.
  • The author recommends Lumiwealth as a resource for detailed, hands-on courses in algorithmic trading and related fields, indicating a belief in the value of quality educational content.
  • By offering a referral link to join Medium, the author subtly endorses the platform as a valuable source of information and learning, emphasizing the benefits of membership for access to a wide range of articles and writers.

Tom Demark’s Rate of Change Indicator for Trading

Creating and Coding the TD Rate of Change Indicator in Python

Tom Demark has created many indicators, among them his own rate of change indicator which is a contrarian indicator based on momentum.

I have released a new book after the success of my previous one “Trend Following Strategies in Python”. It features advanced contrarian indicators and strategies with a GitHub page dedicated to the continuously updated code. If you feel that this interests you, feel free to visit the below Amazon link (which contains a sample), or if you prefer to buy the PDF version, you could check the link at the end of the article.

The Normal 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.

EURUSD hourly data in the first panel with the 10-period rate of change in the second panel.

To code the Rate of Change Indicator in Python, we can use the following function:

def roc(Data, lookback, what, where):
for i in range(len(Data)):
Data[i, where] = ((Data[i, what] - Data[i - lookback, what]) /  Data[i - lookback, what]) * 100             
    
  return Data
USDCHF hourly data in the first panel with the 10-period rate of change in the second panel.

To be able to manipulate the data, we first need to have an OHLC array (not a data frame) and define the following three small manipulation functions:

# 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

Medium is a hub to interesting reads. I read a lot of articles before I decided to start writing. Consider joining Medium using my referral link (at NO additional cost to you).

Tom Demark’s Rate of Change Indicator

The version that Tom Demark has created uses a different lookback period and resembles the Momentum Indicator more than the Rate-of-Change Indicator. The formula for the TD Rate-of-Change is the following:

EURUSD in the first panel with TD ROC in the second panel.
def td_roc_indicator(Data, what, where):
    
    for i in range(len(Data)):
Data[i, where] = Data[i, what] / Data[i - 12, what] * 100       
    
    Data = jump(Data, lookback)
    
    return Data
USDCHF in the first panel with TD ROC in the second panel.

If you want to see how to create all sorts of algorithms yourself, feel free to check out Lumiwealth. From algorithmic trading to blockchain and machine learning, they have hands-on detailed courses that I highly recommend.

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.

Trading
Finance
Cryptocurrency
Bitcoin
Investing
Recommended from ReadMedium