Skip to content

Latest commit

 

History

History
107 lines (70 loc) · 3.91 KB

README.md

File metadata and controls

107 lines (70 loc) · 3.91 KB

@deriv/indicators

In this document

Simple Moving Average

A simple moving average (SMA) is an arithmetic moving average calculated by adding the closing price of the security for a number of time periods and then dividing this total by the number of time periods.

Calculate a single value, from an array of numbers:

Input array of numbers:

const data = [1, 10, 100, 1000, 10000];
const result = simpleMovingAverage(data, { periods: 3 });

Calculate a single value from an array of candles:

const data = [{ close: 1 }, { close: 2 }, { close: 3 }];
const result = simpleMovingAverage(data, { periods: 3, field: 'close' });

Calculate an array of values from an array of numbers:

const data = [1, 2, 3, ...];
const result = simpleMovingAverageArray(data, { periods: 10 });

Exponential Moving Average (EMA)

The 12- and 26-day EMAs are the most popular short-term averages, and they are used to create indicators like the moving average convergence divergence (MACD) and the percentage price oscillator (PPO). In general, the 50- and 200-day EMAs are used as signals of long-term trends.

Bollinger Band (BB)

Bollinger Bands® are volatility bands placed above and below a moving average. Volatility is based on the standard deviation, which changes as volatility increases and decreases. The bands automatically widen when volatility increases and narrow when volatility decreases.

Calculate a single value, from an array of numbers:

Input array of numbers:

const data = [1, 10, 100, 1000, 10000];
const result = bollingerBands(data, { periods: 3 });

Returned value is an array of three items:

[middleValue, upperValue, lowerValue];

Calculate a single value from an array of candles:

const data = [{ close: 1 }, { close: 2 }, { close: 3 }];
const result = bollingerBands(data, { periods: 3, field: 'close' });

Calculate an array of values from an array of numbers:

const data = [1, 2, 3, ...];
const result = bollingerBandsArray(data, { periods: 10 });

Relative Strength Index (RSI)

Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. RSI oscillates between zero and 100.

Moving Average Convergence Divergence (MACD)

Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of prices. The MACD is calculated by subtracting the 26-day exponential moving average (EMA) from the 12-day EMA. A nine-day EMA of the MACD, called the "signal line", is then plotted on top of the MACD, functioning as a trigger for buy and sell signals.


Usage

Indicators

import { simpleMovingAverage } '@deriv/indicators'