Introduction to ATR and Its Practical Use in Quantitative Trading

2021-10-04, 07:26

Fluctuations(https://www.gate.io/en/bitwiki/detail/383) is your “best friend” when you conduct quantitative trading. No matter how great a quantitative strategy is, no satisfactory rate of return will be obtained in a volatile market. Only when the volatility is above a certain level, can there be enough profit margins with quantitative strategies. Therefore, measuring and identifying volatility is essential for making strategies in quantitative trading. The ATR (Average True Range), a market volatility indicator, was proposed by American market technician Welles Wilder JR. This indicator was originally developed for the market analysis for commodities and later applied to investment products such as stocks, foreign exchange, and cryptocurrencies.

What is ATR and What is it used for?

The ATR (Average True Range) is the average difference between the maximum and minimum price for a given trading period over a given time frame. It does not reflect the trend in prices like MA and MACD indicators, but only the degree of price changes. Except for market volatility, it can also indirectly show investors’ sentiments of the market. In general, when sentiment is strong (whether it is optimistic or not), the ATR value will increase.

How to Calculate the ATR:

There are two steps in calculating ATR,
The first step is used to find a series of true range values in every trading period. And the formula for the true range is as follows:

In the above formula, “max()” represents the maximum function; “High” refers to the highest crypto price within the current trading period; “Low” is the lowest price of the cryptocurrency in the current trading week/day; “preClose” denotes the closing price of the crypto coin on the previous trading week/day; “abs()” is the function for absolute value.
If we dissect the mathematical definition formula, the true range(TR) is the max value among them(the current High minus the current Low; the absolute value of the current High minus the previous close, and current Low minus the previous close.)
The second step is used to calculate the average true range in the “N” consecutive trading periods, called the ATR.




Advantages of Using ATR:

ATR embraces the following advantages over standard deviation which is the most common volatility-based indicator.
First, compared to the standard deviation, ATR can more accurately reflect the changes in volatility when the price trend is reversed.
Second, the standard deviation can't reflect the range of price volatility over a trading period, while the ATR can accurately work it. It is more suitable as a reference when trading.

Application of ATR

Again, ATR only reflects price volatility, not the price direction. In general, it is difficult for investors to find buy and sell signals based on a single ATR indicator. More often than not, ATR indicators are applied to composite indicator strategies to figure out market volatility and investor sentiment. The ATR is often used as 14 trading days moving average for the true range and if desired can be used for more or less trading days.
There are two common approaches to use ATR in conjunction with other indicators:
First, the current market trend in volatility can be predicted via the connection between ATR with short periods and with long periods.

Example: when the short-term ATR is greater than the long-term one, it means that short-term volatility is in an enhanced state, and when the short-term ATR is less than the long-term one, it reveals that short-term volatility is entering a weakened state.
ATR is usually used with trend following indicators such as MA and MACD. But in the market without volatility(a rare phenomenon), ATR alone can be used as a judge of price movement trends.
Second, construct price channels with ATR and set buy and sell signals based on logic in channel breakout. Usually, the ATR strategy is incorporated with the MA, using the ATR instead of the standard deviation to build price channels with the logic in Bollinger Band construction. Traders can buy when the current price breaches the upper trendline of the price channel and can sell when the price breaks the lower line of the price channel.

Examples of How to Use ATR:

The first: MA-ATR Strategy
Adding the ATR indicator to the MA strategy can enhance the identification of entry and exit signals. For some mainstream coins, a dual moving average strategy needs to go through a complicated tuning process to achieve profitability. The addition of the ATR indicator can enhance the efficiency of signal recognition in the MA strategy to improve its profitability.
Take the BTC/USDT Perpetual as an example, backtesting is performed using the dual moving average strategy without parameter optimization.
The parameter settings and results are as follows:
Backtest Result:

As you can see, even with 5x leverage, the strategy return is still only 10.33% and the percent profitable is only 32.14%.
With the addition of the true range indicator, the strategy changes from a simple moving average strategy to a composite strategy.

Parameter Setting:

Backtest Result:

It can be observed that after adding the true range indicator, the profitability and percent profitable of the composite strategy are significantly improved without modifying the parameters in the dual moving average strategy, with the returns reaching 178.62%, the percent profitable up to 60%, and the max drawdown falling to 2.66%
(Note: The backtest results in this article are based on historical data and do not guarantee future profitability of the strategy.)

The second: The Strategy for Unilateral-Rise Markets
This strategy is exclusive to the continuously long-term bullish market. The entry point will show when the short-term ATR curve breaks above the long-term one(golden cross), while the exit point will occur when the short-term curve crosses below the long-term one(death cross).

Parameter Setting:
Backtest Result:

According to the backtest results, the strategy has a good performance in a continuous bull market, with a return on investment of 716.6%, a percent profitable of 61.54% and a max drawdown of only 1.84% when setting 10x leverage.

分享一下
gate logo
Credit Ranking
Complete Gate Post tasks to upgrade your rank