Direct answer
ATR (Average True Range) and “trend indicators” that combine ATR with direction are usually calculated from the same basic input: OHLC candle data. ATR uses true range values derived from the current high/low and the previous close. Trend components are then computed using a chosen directional method (for example, moving averages, band logic, or breakout rules). Once you select the exact formulas and parameters, you can reproduce the results on any historical dataset.
Mechanics: definitions and required data
1) What ATR measures
ATR is a volatility metric that estimates how much price typically moves over a lookback window. It does not directly measure direction; it measures magnitude of movement.
Required input data (for each candle):
- High (H)
- Low (L)
- Close (C)
- Previous close (C_prev), meaning the close of the immediately preceding candle
Assumption: You are using a consistent candle series (same timeframe, same session handling, and the same definition of “previous candle”). If you change the timeframe, ATR changes because the inputs change.
2) True Range (TR) formula
For each candle after the first, compute True Range (TR) as the maximum of:
- H − L
- |H − C_prev|
- |L − C_prev|
So, conceptually:
- TR = max(H − L, |H − C_prev|, |L − C_prev|)
The logic is to capture movement that may “gap” relative to the prior close (common when the opening differs sharply from the previous close). Even if you do not have gaps in your market data, the formula still accounts for discontinuities due to candle construction.
3) ATR calculation (rolling average)
ATR is typically the rolling average of TR over N periods (the lookback window):
- ATR_N(t) = average of TR over the last N candles ending at time t
Many platforms implement this average with smoothing (such as Wilder’s smoothing) rather than a simple arithmetic mean. The key point for reproducibility is that you must use the same averaging method and the same N.
Simple moving average (SMA) version (conceptual):
- ATR_N(t) = (TR(t) + TR(t−1) + … + TR(t−N+1)) / N
Smoothed (Wilder-style) version (conceptual):
- You start with an initial ATR equal to the average of the first N TR values.
- Then you update ATR iteratively using the prior ATR and the newest TR.
If a provider says “ATR,” you still need the exact smoothing definition and initial-value handling to match their numbers.
4) What “trend indicators” usually mean in this context
“ATR and trend indicators” commonly refers to a workflow where:
- ATR provides a volatility scale (how large movements tend to be).
- A trend method provides direction or structure (whether price is behaving more like an uptrend or downtrend).
- The two may be combined by using ATR to size bands, offsets, or thresholds.
Because “trend indicators” is not a single universal formula, the calculation depends on the specific trend rule you mean. Common patterns include:
- Moving-average trend: trend is inferred from a moving average, often using its slope or relative position to price.
- Band-based trend: trend state can switch when price crosses bands derived from a baseline plus/minus an ATR-scaled offset.
- Breakout/structure logic: trend state updates when price breaks above/below a rolling level (sometimes that level is ATR-adjusted).
5) Example calculation template (separating stable mechanics from choices)
To compute an ATR-driven trend overlay without locking into one brand formula, use this reproducible template:
- Choose timeframe and candle source (OHLC series).
- Choose ATR window N.
- For each candle t where enough history exists, compute TR(t), then ATR_N(t).
- Choose a trend baseline (one of: moving average, rolling high/low, or another rule).
- Choose how ATR is used with the trend rule:
- Offset bands: baseline ± (k × ATR_N)
- Thresholds: breakout levels adjusted by ATR
- Sizing: step size for a state variable
- Define trend state changes (for example, when price crosses a band or when baseline condition flips).
Assumption: Your chosen method includes explicit “state” rules (how to label trend) and explicit combination rules (how ATR affects the bands/thresholds).
Evidence or example: how to reproduce on your own data
Since no live data or platform-specific details are assumed, here is a generic, checkable workflow.
Step 1: compute TR for each candle
Pick a point where you have at least one previous candle. For candle t:
- Compute H(t) − L(t)
- Compute |H(t) − C(t−1)|
- Compute |L(t) − C(t−1)|
- Take the maximum as TR(t)
Repeat for consecutive candles.
Step 2: compute ATR over N periods
Pick N and an averaging method:
- If the method is an SMA-style ATR, average the last N TR values.
- If the method is Wilder-smoothed, you must follow its iterative update and initial ATR definition.
Step 3: apply a trend rule
Pick one explicit trend definition and test it consistently:
- If using a moving-average approach, compute the baseline (e.g., a moving average) and derive direction from baseline slope or from whether price is above/below it.
- If using ATR bands, compute upper/lower bands using baseline ± (k × ATR) and define a state transition rule (for example, “trend up when close is above upper band” is one possible rule; you must match the exact rule you choose).
Step 4: validate by checking intermediate values
To independently verify, compare at least:
- TR(t) values
- ATR_N(t) at the first point where ATR is defined
- Trend state changes at known candles
If any of these differ from your reference implementation, the most likely causes are:
- Different candle data preprocessing
- Different ATR smoothing (SMA vs Wilder-style)
- Different handling of the first ATR value
- Different trend rule parameters (baseline type, period length, k multiplier)
Limitations and risks (material failure modes)
1) ATR window and smoothing choices can materially change values
ATR depends on N and on how the average is computed. Two implementations can both say “ATR” but still produce different results due to smoothing and initial-value conventions.
2) Trend labeling is not uniquely defined
“Trend indicators” is a category of many different calculations. If you do not specify:
- the baseline method,
- the band/offset logic (if any), and
- the rule for state changes, then the output cannot be uniquely verified.
3) Edge cases at the start of the dataset
Before you have N true range values, ATR is undefined or computed using an initialization rule.