ATR
Calculate the Average True Range (ATR) and True Range (TR) to measure market volatility. The ATR rule quantifies how much a market typically moves over a given period, making it essential for setting dynamic stop losses, position sizing, and filtering trades based on volatility conditions. It supports both standard candle-based inputs and custom source connections for maximum flexibility.
How It Works
The ATR rule first calculates the True Range (TR) for each bar, which is the greatest of the following three values:
- The difference between the current high and the current low (current bar's range)
- The absolute difference between the current high and the previous close (gap up measurement)
- The absolute difference between the current low and the previous close (gap down measurement)
The Average True Range (ATR) is then calculated by applying a moving average to the True Range series over the configured lookback period. By default, a 14-period Running (Wilder) moving average is used, which matches the original ATR specification, but you can choose any of the available moving average algorithms.
The rule supports two source modes:
- Candle — Automatically extracts the High, Low, and Previous Close from a connected candle data source. This is the simplest configuration and works directly with Price Data rule outputs.
- Custom — Allows you to manually connect separate High, Low, and Previous Close sources. This is useful when you want to calculate ATR from non-standard data or when combining values from different sources.
Inputs
| Input | Description | Required | Default |
|---|---|---|---|
| Source Type | Determines how the High, Low, and Previous Close values are provided. Set to Candle to automatically extract values from a candle data source, or Custom to connect individual High, Low, and Previous Close inputs separately. | Yes | Candle |
| Source | The candle data source from which to extract High, Low, and Previous Close values. Used when Source Type is set to Candle. Connect this to a Price Data rule output. | Conditional | — |
| Offset | The number of bars to look back into the historical series before returning the values. An offset of 0 returns the current values, 1 returns the previous bar's values, and so on. | No | 0 |
| High | The high price source for the True Range calculation. Used when Source Type is set to Custom. Connect this to any numeric output representing the high value for each bar. | Conditional | — |
| Low | The low price source for the True Range calculation. Used when Source Type is set to Custom. Connect this to any numeric output representing the low value for each bar. | Conditional | — |
| Previous Close | The previous bar's close price for the True Range calculation. Used when Source Type is set to Custom. Connect this to any numeric output representing the prior close value. | Conditional | — |
| MA Type | The moving average algorithm used to smooth the True Range series into the Average True Range. Available values: Simple, Exponential, Double Exponential, Running, Weighted, Hull, Arnaud Legoux. | No | Running |
| MA Length | The number of data points (bars) used in the ATR moving average calculation. Shorter lengths produce more responsive volatility readings; longer lengths produce smoother, more stable readings. | No | 14 |
| Shift | Controls the offset of the Gaussian weighting curve when the MA Type is set to Arnaud Legoux (ALMA). A value of 0 centres the weight on older data, 1 on newer data, and 0.85 is the standard default. | No | 0.85 |
| Sigma | Controls the width of the Gaussian weighting curve when the MA Type is set to Arnaud Legoux (ALMA). Higher values create a broader, smoother curve. | No | 6.0 |
Outputs
| Output | Description | List |
|---|---|---|
| TR | The True Range value for the current bar (or the bar specified by the Offset). This is the raw, unsmoothed volatility measurement for a single bar, representing the maximum of the current range, gap up, or gap down. | No |
| ATR | The Average True Range value for the current bar (or the bar specified by the Offset). This is the smoothed volatility measurement over the configured lookback period. Connect this to a Simple Calculator rule to set dynamic stop losses (e.g., 2x ATR from entry) or to filter trades based on volatility thresholds. | No |
Tips
The ATR output is commonly used with a Simple Calculator rule to set dynamic stop losses at a multiple of ATR from the entry price (for example, 1.5x or 2x ATR). This automatically adapts your stop distance to current market volatility, placing stops wider during volatile periods and tighter during calm periods. You can also connect the ATR output to a Keltner Channel rule as the Range Value input to build ATR-based volatility envelopes. For position sizing, divide your risk amount by the ATR value to determine the number of units to trade, ensuring consistent risk across varying volatility conditions.
Was this helpful? Let us know