UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

50 lines (49 loc) 1.93 kB
import { ATR as ATRIndicator } from 'technicalindicators'; import { OHLC } from '../types'; import { IndicatorInput, Indicator } from './base-indicator'; export interface AverageTrueRangeInput extends IndicatorInput { period?: number; } /** * The average true range (ATR) is a technical analysis indicator, * introduced by market technician J. Welles Wilder Jr. * in his book New Concepts in Technical Trading Systems, that measures * market volatility by decomposing the entire range of an asset price * for that period. The true range indicator is taken as the greatest * of the following: current high less the current low; the absolute * value of the current high less the previous close; and the absolute * value of the current low less the previous close. The ATR is then a * moving average, generally using 14 days, of the true ranges. */ export declare class ATR implements Indicator { indicator: ATRIndicator; /** * @param {OHLC[]} series candles series * @param {number} period period for indicator */ constructor(series: OHLC[], period?: number); /** * Retrieve ATR values for instance * @return {number[]} values for instance data */ getResults(): number[]; /** * Calculate ATR to next tick * @param {OHLC} candle new candle to add to series * @return {number | undefined} next ATR value or undefined if period is * greater than actual series length */ next(candle: OHLC): number | undefined; /** * Create instance from data * @param {AverageTrueRangeInput} input input data * @return {ATR} ATR instance */ static generator({ series, period }: AverageTrueRangeInput): ATR; /** * Get ATR values from input * @param {AverageTrueRangeInput} input input data * @return {number[]} ATR values */ static calculate({ series, period, }: AverageTrueRangeInput): number[]; }