UNPKG

@4ex/indicators

Version:

Technical indicators for ohlc charts written in TypeScript

52 lines (51 loc) 1.99 kB
import { PSAR as PSARIndicator } from 'technicalindicators'; import { OHLC } from '../types'; import { Indicator, IndicatorInput } from './base-indicator'; export interface ParabolicStopAndReverseInput extends IndicatorInput { step?: number; max?: number; } /** * The parabolic SAR indicator, developed by J. Wells Wilder, is used * by traders to determine trend direction and potential reversals in price. * The indicator uses a trailing stop and reverse method called "SAR" * or stop and reverse, to identify suitable exit and entry points. * Traders also refer to the indicator as the parabolic stop and reverse, * parabolic SAR, or PSAR. * [Investopedia](https://www.investopedia.com/terms/p/parabolicindicator.asp) */ export declare class PSAR implements Indicator { indicator: PSARIndicator; step: number; max: number; /** * @param {OHLC[]} series candles series * @param {number} step step for calculation * @param {number} max max for calculation */ constructor(series?: OHLC[], step?: number, max?: number); /** * Calculate PSAR for specified input * @param {ParabolicStopAndReverseInput} input PSAR input for calculation * @return {number[]} array representing PSAR values */ static calculate(input: ParabolicStopAndReverseInput): number[]; /** * Generate instance of PSAR indicator * @param {ParabolicStopAndReverseInput} input PSAR input for generation * @return {PSAR} instance of indicators */ static generator({ max, step, series, }: ParabolicStopAndReverseInput): PSAR; /** * get values for PSAR instance data * @return {number[]} PSAR values */ getResults(): number[]; /** * Calc PSAR value for next candle * @param {OHLC} candle new candle * @return {number | undefined} next psar value or undefined if period is * greater than actual series length */ next({ low, high }: OHLC): number | undefined; }