Average Day Range (ADR)
Summary
Average Day Range: the arithmetic mean of the last optInTimePeriod bar ranges, high minus low. It answers how far price travels within a bar, and is read as a volatility budget — a stop or a target much smaller than ADR is inside the noise the instrument produces on an ordinary bar, one much larger asks for a move that rarely happens.
Same family as ATR, and deliberately the narrower member: the range excludes the overnight gap, so on a gapping instrument ADR is systematically smaller than ATR. Having both is the point.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive
Formula
Range_t = High_t - Low_t; ADR_t = ( Σ Range over the last optInTimePeriod bars ) / optInTimePeriod
The average is a plain SMA, so there is no seeding convention and none of the cross-library divergence that comes with one.
Notes
- The mean of the ranges, not the difference of the means.
SMA(high) - SMA(low)is algebraically the same quantity and is what both TradingView pages spell, but it subtracts two price-magnitude averages to reach a range-magnitude answer and inherits the larger scale's rounding; TC2000'sAVG(H-L, x)and kand'sSMA(High-Low, period)spell the form implemented here. - The "day" is not a calendar day or a trading session. No TA-Lib function takes a timestamp or a session boundary, so the bars the caller passes are the days — pass daily bars for a daily range, hourly bars for an hourly one. This is the convention VWAP already ships under.
highbelowlowis not rejected. The library validates ranges and parameters, not price sanity, so a bar entered upside down contributes a negative range and the average simply comes out lower, possibly negative, with no error.- Not the width of a Donchian channel.
MAX(high, n) - MIN(low, n)is how far the window's extremes lie apart; ADR is the mean of the per-bar ranges, which is smaller whenever the window trends.DONCHIANships the two extremes that width is built from, not the width itself. - The request this function answers (
TA-Lib/ta-lib-python#575) named "Average Day Range" but the freqtrade code behind it computesMAX(close, 24) - MIN(close, 24), a channel width on the closes with no averaging and no high/low. That is a different series and already reachable, asTA_SUB(TA_MAX(close, 24), TA_MIN(close, 24)). - No percentage form is emitted. The two published ones disagree by more than 20% on ordinary data — Qullamaggie's
100 · (SMA(high/low, 20) - 1)averages ratios, TradingView's(SMA(high, 14) - SMA(low, 14)) / close · 100takes a ratio of averages — so picking one silently would ship a second indicator under this one's name.
Inputs
inHigh— High price of each barinLow— Low price of each bar
Outputs
outReal— Average bar range over the window, in price units
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 14 | 1–100000 | Number of bar ranges averaged. Published conventions differ and none is authoritative: TradingView's ADR indicator page works its example over 7 bars, TC2000's over 10, and the Qullamaggie screener community reads "ADR" as 20. The value shipped here is ATR's, so the two volatility measures are comparable out of the box. |
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_ADR( 0, n - 1, high, low, 14, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.adr(0, high.len() - 1, &high, &low, 14, &mut out)?;
println!("{} values from bar {}: [{:.4}, ..., {:.4}]", range.count, range.beg_idx, out[0], out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.adr(0, high.length - 1, high, low, 14, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%.4f, ..., %.4f]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);using System;
using TALib;
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Adr(0, high.Length - 1, high, low, 14, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { adr } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const { begIdx, values } = adr({ high, low }, { timePeriod: 14 });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0].toFixed(4) + ', ..., ' + values[values.length - 1].toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
high := make([]float64, 252) // your data, oldest first
low := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.ADR(0, len(high)-1, high, low, 14, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%.4f, ..., %.4f]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.8.1 (ta-lib-python 0.8.1).
TA-Lib Definition: adr.c · adr.yaml
| Native | File |
|---|---|
| C | ta_ADR.c |
| Rust | adr.rs |
| Java | Core_ADR.java |
| C# | Core_ADR.cs |
| TypeScript | adr.ts |
| Go | adr.go |
Python: talib.ADR (ta-lib-python 0.8.1 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Average Daily Range
See Also
ATR · DONCHIAN · NATR · QSTICK · TRANGE
References
- TC2000 PCF help, Average Daily Range (ADR) —
AVG(Hz-Lz, x), the mean-of-ranges form, with worked examples over 10 bars. - TradingView, Average Daily Range (ADR) indicator — the difference-of-averages form, over a user-supplied Length and Timeframe.
- TradingView, How are ADR% and ATR% calculated? — the percentage form, and the statement that ADR "does not take gaps into account".
- kand
ohlcv/adr.rs(Rust) statesDaily Range = High - Low; ADR = SMA(Daily Range, period)and is the external implementation the regression goldens are captured from.