The post Average True Range – ATR appeared first on Tuned.

]]>Table of contents

ATR was developed by J. Welles Wilder in the 1970s as a technical indicator that measures the volatility of an asset. This lets traders classify market conditions and/or define stop losses. A good example of using ATR as stop-loss is trend following trading.

It’s important to understand that ATR only measures volatility and doesn’t indicate price direction. It takes an average selection of true ranges over a specific period in time. The true range of an asset can be defined by the greatest absolute value of one of the following:

- |Current High – Current Low|
- |Current High – Previous Close|
- |Current Low – Previous Close|

These true range values are then smoothed over a certain period of time, the most common being 14 periods. With this, traders can use ATR as a filter to classify market conditions or to help These true range values are then smoothed over a certain period of time, the most common being 14 periods. With this, traders can use ATR as a filter to classify market conditions or to help define stop losses.

To calculate ATR we first need to have a period of which the True Range will be smoothed. We will define this period as “n”, which is usually 14.

The formula is defined as:

`Current ATR = ((Prior ATR * (n-1) + Current TR)) /14`

We are multiplying the previous ATR by 13 (n-1), adding the most recent True Range, and dividing the total by 14. The table below should help your understanding.

As we’ve mentioned, there are 2 main use cases for ATR:

- Volatility Filter
- Defining Stop Losses

Using ATR as a Volatility Filter

Most trading systems work best when markets are volatile. This way, ATR can be used to filter conditions. It’s also possible to use ATR as a trend predictor. As we can see in the example below: when the average true range drops and stays low, it can indicate that a new trend will soon form.

Oscillator indicators are typically better suited to algorithmic trading and multiple asset strategies. ATR is not ideal to use as a filter on algorithmic trading because it’s not range-bounded or calculated in a relative way. A different approach is to use a % calculation of the ATR to have a relative calculation to become more user-friendly to automated strategies. This way the ATR displays the volatility as a percentage of the asset and not a fixed number.

Using ATR to define Stop Losses

Another way to use ATR is to define a stop loss. Let’s say an asset has an average true range of 5. When we enter a trade with this volatility in mind we can place the stop loss “x” times the ATR. Meaning that if the price moves more than the average against our trade we can automatically exit our position. This is a common use-case of the ATR indicator for algorithmic trading.

A simple example is to avoid trades when the volatility is low (red) and look for trades when the volatility is high (green).

**Tuned Code** is as follows:

```
//@Tuned 2022 ATR Volatility Filter
//Atr Length
n = intInput("Length",14)
//% TR Calculation
TR = trueRange(high, low, close)/close *100
//% ATR Calculation
ATR = sma(TR, n)
plot(ATR, "ATR%", "#1BC0EB", 1, PlotStyle.LINE, 0, false)
//Signal Push
out(NEVER_ORDER)
```

**Pine Alpha**

```
//Welcome to Tuned!
//Within this editor you will be able to create your strategy
//If you have any questions please ask in Discord
//or review Documentation at https://www.tuned.com/docs/#/
//@version=4
//Tuned supports Pine Version 4 Only
strategy(title="% ATR Snippet", overlay = false)
//Inputs
c = close
n = 14
//Calculations
true_range() =>
max(high - low, max(abs(high - c[1]), abs(low - c[1])))
atr = sma(true_range(), n)
//Plot
plot(atr, title = "ATR%", #004BEC, 2)
```

Most often the ATR indicator is used in algorithmic trading to define stop losses, which works well in strategies requiring a strict set of rules. For example, the turtle trading experiment, where exits were defined as 2 times the stop loss plus the ATR at the moment of the trade. If the price were to move far in the opposite direction, we’d consider the trade invalid and close the position.

Another approach for ATR is as a volatility filter with the modified version explained in the article. In this case, high values indicate volatility and continued low values suggest a new trend will form.

There you have it! Two separate uses for one indicator. We hope you will walk away with a better understanding of ATR and with the encouragement to try experimenting with other indicators.

Happy Trading!

The post Average True Range – ATR appeared first on Tuned.

]]>