UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

57 lines (56 loc) 2.16 kB
import { BollingerBands as BBIndicator } from 'technicalindicators'; import { OHLC, OHLCEnum } from '../types'; import { IndicatorInput, Indicator } from './base-indicator'; export interface BollingerBandsInput extends IndicatorInput { period?: number; source?: OHLCEnum; stdDev?: number; } export interface BollingerBandsOutput { middle: number; upper: number; lower: number; } /** * Bollinger Bands® are a type of chart indicator for technical analysis * and have become widely used by traders in many markets, including stocks, * futures, and currencies. Created by John Bollinger in the 1980s, the bands * offer unique insights into price and volatility. In fact, there are a * number of uses for Bollinger Bands®, such as determining overbought and * oversold levels, as a trend following tool, and for monitoring for breakouts. */ export declare class BB implements Indicator { indicator: BBIndicator; source: OHLCEnum; /** * @param {OHLC[]} series candles series * @param {OHLCEnum} source candles price source * @param {number} period period length * @param {number} stdDev standard deviation */ constructor(series?: OHLC[], source?: OHLCEnum, period?: number, stdDev?: number); /** * Retrieve BB values for instance * @return {BollingerBandsOutput[]} values for instance data */ getResults(): BollingerBandsOutput[]; /** * Calculate BB to next tick * @param {OHLC} candle new candle to add to series * @return {BollingerBandsOutput | undefined} next BB value or undefined if * period is greater than actual series length */ next(candle: OHLC): BollingerBandsOutput | undefined; /** * Create instance from data * @param {BollingerBandsInput} input input data * @return {BB} BB instance */ static generator({ series, period, stdDev, source, }: BollingerBandsInput): BB; /** * Get BB values from input * @param {BollingerBandsInput} input input data * @return {BollingerBandsOutput[]} BB values */ static calculate(input: BollingerBandsInput): BollingerBandsOutput[]; }