+1 888 340 6572 GET STARTED

Bands > Bollinger Bands

Article/Author: Omega Research Inc., 1997

Download: BB.ELA

Category: Indicator > Bands

Description:

The Bollinger Bands indicator calculates a simple arithmetic average of prices, specified by the input Price, from each of the most recent number of bars specified by the input Length. This indicator also calculates the standard deviation in those prices for the same number of bars. An upper band is plotted a specified number of standard deviations above this average and a lower band is plotted a specified number of standard deviations below the average. The average is not plotted.

Usage:

Bollinger Bands combine the trend identifying aspects of a moving average with a dynamic factor, each market’s own volatility, to plot an envelope. The distance between the bands is, therefore, a reflection of volatility. During sideways periods, prices reaching the bands may indicate overbought or oversold conditions. Strong movement up through the upper band or down through the lower band may indicate the beginning of a trend.




Inputs:

Price - Price to be used to calculate the moving average and volatility
Length - Number of bars of data to be included in calculation of Moving Average and volatility
StdDevUp - Number of Standard Deviations added to Moving Average for upper Bollinger Band
StdDevDn - Number of Standard Deviations subtracted from Moving Average for lower Bollinger Band
Displace - Number of bars to displace the plot of the Bollinger Bands

EasyLanguage Code:
INPUT: 	PRICE(CLOSE), LENGTH(9), STDDEVUP(2), STDDEVDN(-2), DISPLACE(0);

VARIABLES: BBTOP(0), BBBOT(0);

BBTOP = BOLLINGERBAND(PRICE, LENGTH, STDDEVUP);
BBBOT = BOLLINGERBAND(PRICE, LENGTH, STDDEVDN);

IF DISPLACE >= 0 OR CURRENTBAR > ABSVALUE(DISPLACE) THEN BEGIN
PLOT1[DISPLACE](BBTOP, "BOLLTOP");
PLOT2[DISPLACE](BBBOT, "BOLLBOT");

{ALERT CRITERIA}
CONDITION1 = PLOT1 <> PLOT2;
IF PRICE > PLOT1 AND CONDITION1 THEN
ALERT("PRICE IS OVER THE TOP BAND")
ELSE
IF PRICE < PLOT2 AND CONDITION1 THEN
ALERT("PRICE IS UNDER THE BOTTOM BAND");
END;