Mathematical Description of Technical Indicators

Overview

This document contains mathematical description of all technical indicators available in AnyChart Stock Component.

For all formulas and indicators below:

to top

Accumulation Distribution Line (ADL)

Accumulation Distribution Line is calculated according to these formulas:

to top

Adaptive Moving Average (AMA)

AMA overlay in each point is calculated according to the following calculation sequence:

to top

Aroon

Aroon indicator in each point is calculated according to the following formula:

to top

Average True Range (ATR)

Average True Range in each point is calculated according to the following formula:

This formula is based on the True Range definition. TR is defined as the greatest of the following:

to top

Bollinger Bands (BBands)

Bollinger Bands values in each point are calculated in three steps:

  1. SMAi is calculated according to Simple Moving Average formula.
  2. Standard deviation is calculated as:
  3. Bollinger Bands values are calculated according to this formula, where d is set using deviation attribute in <bbands_indicator> node:

to top

BBands %B

Bollinger Bands %B indicator is calculated according to this formula:

You can see how Bollinger Upper and Lower Bands are calculated in the BBands part of this article.

to top

BBands Width

Bollinger Bands Width indicator is calculated according to this formula:

You can see how Bollinger Upper and Lower Bands are calculated in the BBands part of this article.

to top

Commodity Channel Index (CCI)

Commodity Channel Index is calculated according to this formula:

Where TP is a Typical Price calculated as:

And SMA is calculated as stated in SMA part of this article.

to top

Chaikin Money Flow (CMF)

Chaikin Money Flow is calculated in three steps:

  1. First a MFMi is calculated for all points according to this formula:
  2. Next an MFVi value is calculated for all points like this:
  3. And finally the CMFi value is calculated according to this formula:

to top

Chaikin Oscillator (CHO)

Chaikin Oscillator is calculated according to this formula:

You can see how the ADL indicator is calculated in the ADL part of this article.

to top

Chaikin Volatility (CHV)

Chaikin Volatility indicator in each point is calculated according to the following formula:

to top

Directional Movement Indicator (DMI)

Directional Movement Indicator is calculated in three steps:

  1. First the True Range (TR), Plus Directional Movement (+DM) and Minus Directional Movement (-DM) are calculated for each period:
  2. Next they are smoothed using EMA or Wilder's method, calculated as:
  3. And finally the +DI and -DI values are calculated according to these formulas:

to top

Exponential Moving Average (EMA)

Exponential Moving Average in each point is calculated according to the following formula:

to top

Keltner Channels

Keltner Channels bands in each point are calculated according to the following formulas:

You can see how EMA (Exponential Moving Average) and ATR (Average True Range) indicators are calculated in corresponding sections of this article.

to top

Modified (Smoothed) Moving Average (MMA)

Modified Moving Average indicator is quite similar to a Simple Moving Average and is calculated according to the following formula:

to top

Money Flow Index (MFI)

Money Flow Index is calculated as follows:

  1. The typical price for each day is the average of high, low and close:
  2. Money flow is the product of typical price and the volume on that day:
  3. Totals of the money flow amounts over the given N days are then formed. Positive money flow is the total for those days where the typical price is higher than the previous day's typical price, and negative money flow where below. If typical price is unchanged then that day is discarded.
  4. A money ratio is then formed:
  5. From which a money flow index ranging from 0 to 100 is formed:

to top

Momentum

Momentum indicator in each point is calculated in accordance to the folowing formula:

to top

Moving Average Convergence/Divergence (MACD)

Moving Average Convergence/Divergence indicator is calculated as follows:

  1. EMA[slow period]i and EMA[fast period]i is calculated by EMA formula. Slow period and fast period are set by slow_period (default 26) and fast_period (default 12) attributes of <macd_indicator > node.
  2. MACD series value is calculated:
  3. EMA[signal period]i of MACD series values is calculated by EMA formula, where signal period is set by signal attribute of <macd_indicator > node.
  4. Signal series value is calculated:
  5. Histogram series is calculated:

to top

Moving Average Envelopes (MA Envelopes)

Moving Average Envelopes are calculated according to the following formulas:

to top

On Balance Volume (OBV)

On Balance Volume indicator is calculated according to the folowing rules:

to top

Parabolic SAR (PSAR)

Parabolic SAR is created according to the following algorithm.

At each step within a trend, the SAR is calculated ahead of time. That is, tomorrow's SAR value is built using data available today. The general formula used for this is:

Where SARi and SARi - 1 represent today's and tomorrow's SAR values, respectively.

The extreme point, EP, is a record kept during each trend that represents the highest value reached by the price during the current up trend — or lowest value during a downtrend. On each period, if a new maximum (or minimum) is observed, the EP is updated with that value.

The α value represents the acceleration factor. Usually, this is set to a value of 0.02 initially. This factor is increased by 0.02 each time a new EP is recorded. Initial values is set using step_period attribute of <psar_indicator> node.

To keep it from getting too large, a maximum value for the acceleration factor is normally set at 0.20, so that it never goes beyond that. Maximum value for the acceleration factor is set using max_step_period attribute of <psar_indicator> node.

The SAR is recursively calculated in this manner for each new period. There are, however, two special cases that will modify the SAR value:

to top

Price Channels

Price Channels bands are calculated according to the following formulas:

to top

Rate of Change (ROC)

Rate of Change is calculated according to this formula:

to top

Relative Strength Index (RSI)

Relative Strength Index is calculated as follows:

  1. Upward change (U) or downward change (D) sequences are calculated:
  2. Then two averages are calculated:

  3. And final RSI formula is :

to top

Simple Moving Average (SMA)

Simple Moving Average in each point is calculated according to the following formula:

to top

Stochastic Oscillator (Full)

Stochastic Oscillator is calculated as follows:

to top

TRIX

TRIX indicator and its signal line are calculated in accordance to the folowing calculation flow:

to top

Volume + MA

Volume + MA does no calculations with Volume and adds moving average of either SMA or EMA type calculated from Volume series. The type is set using ma_type attribute of <volume_ma_indicator> node.

to top

Williams %R

Williams %R is calculated according to this formula:

to top