UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

65 lines (64 loc) 2.8 kB
import { StochasticRSI as StochRSIIndicator } from 'technicalindicators'; import { StochasticRsiInput, StochasticRSIOutput as SRSIOutput } from 'technicalindicators/declarations/momentum/StochasticRSI'; import { OHLC, OHLCEnum } from '../types'; import { IndicatorInput, Indicator } from './base-indicator'; declare type Input = IndicatorInput & Partial<Omit<StochasticRsiInput, 'values'>>; export interface StochasticRSIInput extends Input { source?: OHLCEnum; } export declare type StochasticRSIOutput = SRSIOutput; /** * The Stochastic RSI (StochRSI) is an indicator used in technical analysis * that ranges between zero and one (or zero and 100 on some charting * platforms) and is created by applying the Stochastic oscillator formula * to a set of relative strength index (RSI) values rather than to standard * price data. Using RSI values within the Stochastic formula gives traders an * idea of whether the current RSI value is overbought or oversold. * The StochRSI oscillator was developed to take advantage of both momentum * indicators in order to create a more sensitive indicator that is attuned to * a specific security's historical performance rather than a generalized * analysis of price change. */ export declare class StochRSI implements Indicator { indicator: StochRSIIndicator; source: OHLCEnum; kPeriod: number; dPeriod: number; rsiPeriod: number; stochasticPeriod: number; /** * * @param {OHLC[]} series candles series * @param {OHLCEnum} source source of values * @param {number} kPeriod * @param {number} dPeriod * @param {number} rsiPeriod * @param {number} stochasticPeriod */ constructor(series: OHLC[], source?: OHLCEnum, kPeriod?: number, dPeriod?: number, rsiPeriod?: number, stochasticPeriod?: number); /** * Retrieve StochRSI values for instance * @return {StochasticRSIOutput[]} values for instance data */ getResults(): StochasticRSIOutput[]; /** * Calculate StochRSI to next tick * @param {OHLC} candle new candle to add to series * @return {StochasticRSIOutput | undefined} next StochRSI value or * undefined if period is greater than actual series length */ next(candle: OHLC): StochasticRSIOutput | undefined; /** * Create instance from data * @param {StochasticRSIInput} input input data * @return {StochRSI} StochRSI instance */ static generator({ series, source, kPeriod, dPeriod, rsiPeriod, stochasticPeriod, }: StochasticRSIInput): StochRSI; /** * Get StochRSI values from input * @param {StochasticRSIInput} input input data * @return {StochasticRSIOutput[]} StochRSI values */ static calculate(input: StochasticRSIInput): StochasticRSIOutput[]; } export {};