Some TA Indicator Formulae

Hope this helps

1) Simple Moving Average:

The simple moving average sums the prices (you can choose from the closing price, the VWAP time-weighted price or the high/low/close average price) for a specific number of data points and divides by that number. The calculation for a 3-bar simple moving average is:
(price_1) + (price_2) + (price_3) divided by 3

2) Weighted Moving Average:

The weighted moving average gives each data point a weight proportionate to its number in the sequence and divides by the sum of its weights. The calculation for a 3-bar weighted moving average is:
(1 x price_1) + (2 x price_2) + (3 x price_3) divided by 6, where 6 is the sum of the weights (1 + 2 + 3).

3) Exponential Moving Average:

The exponential moving average gives more weight to the latest prices and includes all of the price data in the life of the instrument. It is defined by taking:
(previous period's exponential moving average)/(N+1) and adding (current price)*2/(N+1). For the first period we take the simple average as above.

4) Envelope:

SMA/WMA/EMA Envelopes plot a band composed of two moving averages, one which is shifting upwards, the other shifting downwards, to help define a stock's upper and lower boundaries. The bands of an envelope are calculated as follows:

Upper Band = MA(CLOSE, N)*[1+K/100]
Lower Band = MA(CLOSE, N)*[1-K/100]
MA = Simple (or Weighted or Exponential) Moving Average;
N = averaging period;
K/100 = the value of shifting from the average (measured in basis points).

5) Bollinger Bands:

Bollinger Bands measure volatility by plotting a series of three bands. The middle band represents the moving average (SMA or WMA or EMA). The upper band is a set number of standard deviations higher than the middle band (generally 2), and the lower band is a set number of standard deviations (generally 2) lower than the middle band. You set the distance of standard deviation when you create the study.
Bollinger Bands are calculated like this:

ML = Avg. (N)
TL = ML + (D*StdDev)
BL = ML - (D*StdDev)

ML = middle line
Avg(N) = SMA or WMA or EMA
TL = top line
BL = bottom line
N = is the number of periods used in calculation;
StdDev = the Standard Deviation.

6) Parabolic SAR:

For use in trending markets, parabolic SAR uses a trailing stop and reverse method to help determine good exit and entry points. The Parabolic SAR calculation is:

SARt+1 = SARt+ AF x (EPtrade x SARt)


SARt+1 = next period's SAR
SARt = current SAR
AF = acceleration factor, begins at .02 and increases by .02 to a maximum of 20.
NOTE: You can reset the initial, increments and maximum acceleration factor when you create the study.

EPtrade = the extreme price (HIGH for long positions and LOW for short positions).

7) Relative Strength Indicator:

The RSI indicator is for overbought/oversold conditions. It goes up when the market is strong, and down when the market is weak, and oscillates between 0 -100. The RSI calculation is:
RSI = 100-(100/1+RS)

RS = Average of X bars Up Closes/Average X bars Down Closes (X=number of bars set by user)

8) Moving Average Convergence/Divergence (MACD):

This is a trend-following dynamic indicator that shows the correlation between two moving averages, generally a 26-period and 12-period SMA or WMA or EMA. You can modify the period length when you create the study. To help illustrate opportunity, a 9-period EMA "signal line" is plotted on top of the MACD.
The MACD and signal line are plotted using the following calculations:




MA = Simple or Weighted or Exponential Moving Average;
SIGNAL = the signal line of the indicator.


The ADX/DMI is represented by three lines +DM, -DM and ADX.

The Directional movement
If today's High is higher than yesterday's High then:
+DM = today's High - yesterday's High

If today's Low is lower than yesterday's Low then:
-DM = yesterday's Low - today's Low

If +DM is greater than -DM then:-DM = 0
If +DM is less than -DM then:+DM = 0

The true range
True range is the largest of:
|today's High - today's Low|
|today's High - yesterday's Close|
|yesterday's Close - today's Low|

Moving average of +DM, -DM and True Range
+DMMA = exponential moving average of +DM
-DMMA = exponential moving average of -DM
TRMA = exponential moving average of True Range

The Directional Indicators

Directional Index
DX = |(+DI - (-DI))| / (+DI + (-DI))

The Average Directional Movement Index
ADX = the exponential moving average of DX
ADX = SUM[(+DI-(-DI))/(+DI+(-DI)), N]/N
N the number of periods used in the calculation.

10) Stochastic Oscillator:

The stochastic oscillator provides information about the location of a current close in relation to the period's high and low. It ranges between 0% and 100%. A reading of 0% indicates that the close was the lowest price at which the security traded during the preceding x number of time periods. A reading of 100% indicates that the close was the highest price at which the security traded during the preceding x number of time periods.

NOTE: You can specify the method (SMA, WMA or EMA), observation period, period of slow average and period of fast average when you create the study.

11) On Balance Volume:

The concept behind the OBV indicator is: volume precedes price. OBV is a simple indicator that adds a period's volume when the close is up and subtracts the period's volume when the close is down. A cumulative total of the volume additions and subtractions forms the OBV line.

If todays close is greater than yesterdays close then: OBV(i) = OBV(i-1)+VOLUME(i)
If todays close is less than yesterdays close then: OBV(i) = OBV(i-1)-VOLUME(i)
If todays close is equal to yesterdays close then: OBV(i) = OBV(i-1)

OBV(i) is the indicator value of the current period.
OBV(i-1) is the indicator value of the previous period.
VOLUME(i) is the volume of the current bar.

12) Rate of Change:

ROC is a refined version of Momentum. The readings fluctuate as percentages around the zero line. You set the number of periods when you create the study.

Rate of change =100(V/Vx)
V - the latest closing price.
Vx - the closing price of x bars ago.

13) Momentum:

The Momentum is the difference between the current point (price or something else) and the point N periods ago. Momentum is calculated as a ratio of todays price to the price several (N) periods ago.

Momentum = CLOSE(i)-CLOSE(i-N)

CLOSE(i) = the closing price of the current bar.
CLOSE(i-N) = the closing bar price N periods ago

14) Average True Range:

The Average True Range indicator is used to determine the volatility of the market. The idea is to replace the high-low interval for the given period, as the high-low does not take into consideration gaps and limit moves.
You set the period when you create the study.

The True Range is the largest of:
difference between the current maximum and minimum (high - low)
difference between the previous closing price and the current maximum
difference between the previous closing price and the current minimum
The Average True Range is a simple moving average of the true range values.

15) Ultimate Oscillator:

The Ultimate Oscillator combines the price action for three different time frames. You set the observations periods 1, 2, and 3 when you create the study.

Time Frames:
true low = min(low or prev close)
buying pressure = close - true low
true range = max(high - low, high - prev close, prev close - low)

Buying pressure sum 1, buying pressure sum 2 and buying pressure sum 3 are calculated by adding up buying pressures for 3 different time frames.

The same applies to the true range sum 1, 2 and 3.

raw ultimate oscillator = 4 * (buying pressure sum 1 / true range sum 1)
+ 2 * (buying_pressure_sum_2 / true_range_sum_2) + (buying_pressure_sum_3 / true_range_sum_3)

ultimate oscillator = raw ultimate oscillator / (4 + 2 + 1) ) * 100

16) Williams Oscillator:

The Williams Percent Range (%R) indicator identifies the overbought/oversold levels. The scale extends from 0 to -100.

%R = (HIGH(i-n)-CLOSE)/(HIGH(i-n)-LOW(i-n))-100

CLOSE = is todays closing price.
HIGH(i-n) = is the highest high over a number (n) of previous periods.
LOW(i-n) = is the lowest low over a number (n) of previous periods.

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Are you a day trader?