File Includes: Indicator - Mov Avg EnvDisp
Category: Indicator > Trend Identificator
This indicator plots the Moving Average Displaced Envelopes. This indicator plots 2 moving averages which are calculated using price data from the same number of bars, per the input Length. Moving averages are recognized for their value in identifying trends. Using moving averages of highs and lows, and adjusting them for a fixed percentage, can be helpful in finding extreme conditions of overbought or oversold and in identifying trading ranges.
Bands define the upper and lower boundaries of a security's normal trading range. A sell signal is generated when the security reaches the upper band whereas a buy signal is generated at the lower band. The optimum percentage shift depends on the volatility of the security - the more volatile, the larger the percentage.
The logic behind bands is that overzealous buyers and sellers push the price to the extremes (i.e., the upper and lower bands), at which point the prices often stabilize by moving to more realistic levels.
Price - the data series to average
Length - the parameter tells how many bars to average
PrcntAbv - percentage of upward shift
PcntBlw - percentage fo downward shift
Displace - number of bars to displace the plot of the moving average
INPUT: PRICE(CLOSE),LENGTH(9),PRCNTABV(.5),PRCNTBLW(.5), DISPLACE(13);
IF DISPLACE>=0 THEN BEGIN
IF CURRENTBAR>DISPLACE THEN BEGIN
PLOT1(AVERAGE(PRICE,LENGTH)[DISPLACE] * (100 + PRCNTABV) / 100,"PRCNTABV");
PLOT2(AVERAGE(PRICE,LENGTH)[DISPLACE] * (100 - PRCNTBLW) / 100,"PRCNTBLW");
IF DISPLACE<0 THEN BEGIN
IF CURRENTBAR>ABSVALUE(DISPLACE) THEN BEGIN
PLOT1[ABSVALUE(DISPLACE)](AVERAGE(PRICE,LENGTH) * (100 + PRCNTABV) / 100,"PRCNTABV");
PLOT2[ABSVALUE(DISPLACE)](AVERAGE(PRICE,LENGTH) * (100 - PRCNTBLW) / 100,"PRCNTBLW");
IF CHECKALERT THEN BEGIN
IF (TRUEHIGH >= PLOT1 AND TRUELOW <= PLOT1)
OR (TRUEHIGH >= PLOT2 AND TRUELOW <= PLOT2)
THEN ALERT = TRUE;