UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

50 lines (49 loc) 1.83 kB
import { ROC as ROCIndicator } from 'technicalindicators'; import { OHLC, OHLCEnum } from '../types'; import { IndicatorInput, Indicator } from './base-indicator'; export interface RateOfChangeInput extends IndicatorInput { period?: number; source?: OHLCEnum; } /** * The rate of change (ROC) is the speed at which a variable changes * over a specific period of time. ROC is often used when speaking * about momentum, and it can generally be expressed as a ratio between * a change in one variable relative to a corresponding change in another; * graphically, the rate of change is represented by the slope of a line. * The ROC is often illustrated by the Greek letter delta. */ export declare class ROC implements Indicator { indicator: ROCIndicator; source: OHLCEnum; /** * @param {OHLC[]} series candles series * @param {OHLCEnum} source source of values * @param {number} period period for indicator */ constructor(series: OHLC[], source?: OHLCEnum, period?: number); /** * Retrieve ROC values for instance * @return {number[]} values for instance data */ getResults(): number[]; /** * Calculate ROC to next tick * @param {OHLC} candle new candle to add to series * @return {number | undefined} next ROC value or undefined if period is * greater than actual series length */ next(candle: OHLC): number | undefined; /** * Create instance from data * @param {RateOfChangeInput} input input data * @return {ROC} ROC instance */ static generator({ series, source, period, }: RateOfChangeInput): ROC; /** * Get ROC values from input * @param {RateOfChangeInput} input input data * @return {number[]} ROC values */ static calculate(input: RateOfChangeInput): number[]; }