Kaufman Efficiency Ratio (ER)
Summary
Kaufman Efficiency Ratio (also searched as "KER"): Perry Kaufman's noise measure from Smarter Trading (1995) — the net directional movement over the period divided by the total path travelled to get there. 1.0 is a perfectly efficient (straight-line) move; values near 0 are churn.
This is exactly the efficiency ratio KAMA computes internally to set its adaptive smoothing constant, exposed standalone and kept bit-identical to it.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive
Formula
ER[t] = |close[t] − close[t−P]| / Σ |close[k] − close[k−1]| over the same P bars.
Two guards, both shared with KAMA: a ratio that floating point would nudge just above 1.0 on a straight-line advance is pinned to exactly 1.0, and a dead-flat window (0/0) also reports 1.0 — a flat market therefore reads as "perfectly efficient", which is KAMA's own convention and what keeps the two reconstructible from each other.
The output is a hard 0..1 — the net move can never exceed the path travelled.
TC2000 documents a signed ×100 variant (−100..+100); the absolute 0..1 form here is the author's, StockCharts', LEAN's, backtrader's and pandas-ta's.
Inputs
inReal— Source price/value series (canonically close)
Outputs
outReal— Efficiency ratio
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 10 | 2–100000 | Number of one-bar changes in the path sum (KAMA's optInTimePeriod is the same window, under its own default) |
Notes
- First output at index
P(Pone-bar changes needP+1prices). No unstable period, not start-dependent.
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 series[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_ER( 0, n - 1, series, 10, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let series = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.er(0, series.len() - 1, &series, 10, &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[] series = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.er(0, series.length - 1, series, 10, 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 series = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Er(0, series.Length - 1, series, 10, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { er } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const { begIdx, values } = er(series, { timePeriod: 10 });
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"
)
series := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.ER(0, len(series)-1, series, 10, 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: er.c · er.yaml
| Native | File |
|---|---|
| C | ta_ER.c |
| Rust | er.rs |
| Java | Core_ER.java |
| C# | Core_ER.cs |
| TypeScript | er.ts |
| Go | er.go |
Python: talib.ER (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
Efficiency Ratio · Kaufman Efficiency Ratio · KER
See Also
References
- Perry Kaufman, Smarter Trading: Improving Performance in Changing Markets (McGraw-Hill, 1995) — the efficiency ratio and the adaptive moving average built on it
- Perry Kaufman, Trading Systems and Methods, 6th ed. (Wiley, 2019), the "Efficiency Ratio" section