/** * True range, and the two averages of it. * * **Bar 0 is the one deliberate exception to absence propagation in this * library**, and `stdlib.md` section 6 puts it there rather than leaving it to * an engine. `trueRange()` on bar 0 is `high - low`: the other two terms need * the previous close, which does not exist there, and propagating absence would * start `atr` one bar later than every reference implementation while adding * nothing, because the bar's own range is a true statement about that bar. * * The exception is granted to `trueRange` and therefore to `atr` and `natr`. * It is not granted to every function that happens to use a range: where a * function's declared warmup shows it counts changes rather than levels, * `gapTrueRange` is the form it uses, and that one is absent on bar 0 like any * other change. `chop` and `adx` are the two, and both of their warmups in * `stdlib.md` are one bar later than the plain reading would give, which is how * the specification says which form they take. * * **Where the previous close comes from is a host fact, not an arithmetic one.** * A run of bars has it in the bar before; an engine is handed it with the bar, * and that is the one it must use, because a call inside a branch does not see * every bar and the close of the bar it last ran on is a different number. So * the arithmetic below takes it as an argument and `gapOf` is the small piece * that remembers it for a caller folding over a series. */ import type { Bar, StateRecord, Tail, Value } from '../values/index.js'; /** A bar's two extremes and the close before it, which is what a range needs. */ export interface Gap { readonly high: Value; readonly low: Value; /** The close of the bar before this one, absent on the first bar. */ readonly previousClose: Value; /** Whether this is the first bar of the run. */ readonly isFirstBar: boolean; } /** `trueRange()`: the bar's range including any gap from the previous close. */ export declare function trueRangeOf(gap: Gap, allowFirstBar: boolean): Value; /** * The previous close remembered in a region, for a caller folding over a run of * bars rather than being handed one at a time. */ export declare function gapOf(state: StateRecord, key: string, bar: Bar): Gap; /** `trueRange()` as a tail. */ export declare function trueRangeTail(): Tail; /** * True range with no exception on bar 0, as a step: absent there, like any * other quantity that needs the bar before it. Not a call a script can make; * see this file's opening note for which functions use it and why. */ export declare function gapTrueRangeStep(state: StateRecord, key: string, bar: Bar): Value; /** `trueRange()` over a run of bars. */ export declare function trueRange(bars: readonly Bar[]): Value[]; /** The gap-aware true range as a tail. */ export declare function gapTrueRangeTail(): Tail; /** The gap-aware true range over a run of bars. */ export declare function gapTrueRange(bars: readonly Bar[]): Value[]; /** `atr(len)`: the smoothed mean of true range, from bar `len - 1`. */ export declare function atrStep(state: StateRecord, key: string, gap: Gap, len: number | null): Value; /** `atr(len)` as a tail. */ export declare function atrTail(len: number): Tail; /** `atr(len)` over a run of bars. */ export declare function atr(bars: readonly Bar[], len?: number): Value[]; /** `natr(len)`: `atr` as a percentage of close, from bar `len - 1`. */ export declare function natrStep(state: StateRecord, key: string, gap: Gap, close: Value, len: number | null): Value; /** `natr(len)` as a tail. */ export declare function natrTail(len: number): Tail; /** `natr(len)` over a run of bars. */ export declare function natr(bars: readonly Bar[], len?: number): Value[]; //# sourceMappingURL=range.d.ts.map