avatarSofien Kaabar, CFA

Summary

The article presents a method for transforming the Average True Range (ATR) indicator into a directional trend-following tool known as the Smoothed Normalized ATR (SNATR), and outlines a trading strategy based on this indicator.

Abstract

The article details the creation of the Smoothed Normalized ATR (SNATR), an evolution of the traditional ATR indicator designed to provide directional insights into market trends. The SNATR normalizes and smooths the ATR values to create a bounded oscillator that can indicate trend reversals. The strategy involves using the SNATR in conjunction with a moving average to generate buy and sell signals based on specific thresholds. The author emphasizes the importance of optimizing the strategy for individual markets while being cautious of overfitting. Additionally, the article suggests that the SNATR can be particularly useful in identifying bullish and bearish trends by predicting lower and higher ATR values, respectively. The author provides the source code for implementing the strategy and promotes further learning through a book on financial pattern recognition.

Opinions

  • The author believes that the SNATR can be a valuable tool for traders looking to follow trends by transforming the ATR into a bounded oscillator.
  • The strategy presented is not a one-size-fits-all solution; it requires parameter optimization and caution against overfitting.
  • The article posits that bullish trends are associated with low volatility and bearish trends with high volatility, which the SNATR aims to predict.
  • The author suggests that financial pattern recognition, including the use of indicators like the SNATR, is a complex but learnable skill, promoting their book as a resource for further education.
  • The author endorses an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4), indicating a belief in the value of AI tools for trading and analysis.

Use This Indicator to Follow The Trend

Creating and Coding the Smoothed Normalized ATR Indicator

Volatility indicators are helpful in detecting trends. This article shows how to transform the ATR into a directional indicator and create a strategy out of it.

Creating the Smoothed Normalized ATR (SNATR)

The average true range (ATR) is a technical analysis indicator that measures volatility in financial markets. It was introduced by J. Welles Wilder Jr. in his 1978 book, “New Concepts in Technical Trading Systems.” The ATR calculates the average of a security’s true range over a specified period, usually 14 days. The true range is the greatest of the following:

  • The current period’s high minus the current period’s low.
  • The absolute value of the current period’s high minus the previous period’s close.
  • The absolute value of the current period’s low minus the previous period’s close.

The ATR is the smoothed moving average of the true range calculations. By using these three values, the ATR measures the volatility of a security over a certain time period, taking into account any gaps or price movements that occur between periods. Traders can use the ATR to determine the potential size of price movements and adjust their trading strategies accordingly. For example, a high ATR value may indicate that a security is more volatile and therefore riskier to trade.

The SNATR is a simple transformation of the ATR to make it bounded. The steps to calculate it are as follows:

  • Calculate the ATR of a financial instrument using whichever lookback period required.
  • Normalize the ATR between 0 and 1 using the basic normalization function defined below:
  • Calculate a 13-period weighted moving average on the normalized values from the previous step.

The following Figure shows the SNATR in action:

EURUSD with the Smoothed Normalized ATR

Coding the Strategy

Bear in mind that the presented strategy has default parameters that must be optimized for each market (while incorporating the risk of overfitting), therefore, it may not work well on all markets. You should take the idea of the strategy and try to make it better.

Trend following generally two theoretical ideas:

  • The first idea is that bullish trends generally have low volatility, therefore, if we can predict lower values on the ATR, we may be entering a bullish trend.
  • The second idea is that bearish trends generally have high volatility, therefore, if we can predict higher values on the ATR, we may be entering a bearish trend.

The strategy tries to predict a reversal on the SNATR the moment it shows a return to normality while at the same time a moving average filter confirms this. Below are the trading conditions:

  • A long signal is generated whenever the SNATR dips below 0.80 while the close price is above the 100-period moving average
  • A short signal is generated whenever the SNATR rises above 0.20 while the close price is below the 100-period moving average.
Signal chart

The code for the strategy 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("ATR Strategy", overlay = true)
atr = ta.atr(60)

normalized_atr = (atr - ta.lowest(atr, 60)) / ((ta.highest(atr, 60)) - ta.lowest(atr, 60))
smoothed_normalized_atr = ta.wma(normalized_atr, 13)

buy  = smoothed_normalized_atr < 0.8 and smoothed_normalized_atr[1] > 0.8 and close > ta.sma(close, 100)
sell = smoothed_normalized_atr > 0.2 and smoothed_normalized_atr[1] < 0.2 and close < ta.sma(close, 100)

plotshape(buy,  style = shape.triangleup, color = color.green, location =  location.belowbar, size = size.small)
plotshape(sell,  style = shape.triangledown, color = color.red, location =  location.abovebar, size = size.small)
Signal chart

The following Figure shows another signal chart on Tesla:

Signal chart

Financial pattern recognition is no easy task, and the best way to dip your toes in this field is through candlestick pattern recognition. Learn how to detect classic and modern patterns using Python in my book published with O’Reilly Media! A dedicated GitHub is provided.

Trading
Investing
Finance
Economics
Stock Market
Recommended from ReadMedium