UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

50 lines (49 loc) 2.02 kB
import { CCI as CCIIndicator } from 'technicalindicators'; import { OHLC } from '../types'; import { IndicatorInput, Indicator } from './base-indicator'; export interface CommodityChannelIndexInput extends IndicatorInput { period?: number; } /** * The CCI, or Commodity Channel Index, was developed by Donald Lambert, * a technical analyst who originally published the indicator in Commodities * magazine (now Futures) in 1980. Despite its name, the CCI can be used * in any market and is not just for commodities. The CCI was originally * developed to spot long-term trend changes but has been adapted by traders * for use on all markets or timeframes. Trading with multiple timeframes * provides more buy or sell signals for active traders. Traders often use the * CCI on the longer-term chart to establish the dominant trend and on the * shorter-term chart to isolate pullbacks and generate trade signals. */ export declare class CCI implements Indicator { indicator: CCIIndicator; /** * @param {OHLC[]} series candles series * @param {number} period period for indicator */ constructor(series: OHLC[], period?: number); /** * Retrieve CCI values for instance * @return {number[]} values for instance data */ getResults(): number[]; /** * Calculate CCI to next tick * @param {OHLC} candle new candle to add to series * @return {number | undefined} next CCI value or undefined if period is * greater than actual series length */ next(candle: OHLC): number | undefined; /** * Create instance from data * @param {CommodityChannelIndexInput} input input data * @return {CCI} CCI instance */ static generator({ series, period }: CommodityChannelIndexInput): CCI; /** * Get CCI values from input * @param {CommodityChannelIndexInput} input input data * @return {number[]} CCI values */ static calculate({ series, period, }: CommodityChannelIndexInput): number[]; }