Category: Indicator > Averages
The moving average may be the most widely used indicator. The Mov Avg 1 line indicator calculates and plots 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.
A moving average is generally used for trend identification. Attention is given to the direction in which the average is moving and to the relative position of prices and the moving average. Rising moving average values (direction) and prices above the moving average (position) would indicate an uptrend. Declining moving average values and prices below the moving average would indicate a downtrend. A displaced moving average plots the moving average value of a previous bar or later bar on the current bar.
Price - Value to be used in calculating the Moving Average
Length - Number of bars of data to be included in calculation
Displace - Number of bars to displace the plot of the Moving Average
INPUTS: PRICE(CLOSE), LENGTH(9), DISPLACE(0);
IF DISPLACE >= 0 OR CURRENTBAR > ABSVALUE(DISPLACE) THEN BEGIN
PLOT1[DISPLACE](AVERAGEFC(PRICE, LENGTH), "SIMPAVG1");
IF PRICE < PLOT1 AND PLOT1 < PLOT1 AND PLOT1 > PLOT1 THEN
ALERT("THE MOVING AVERAGE HAS JUST CHANGED DIRECTION AND IS NOW BULLISH")
IF PRICE > PLOT1 AND PLOT1 > PLOT1 AND PLOT1 < PLOT1 THEN
ALERT("THE MOVING AVERAGE HAS JUST CHANGED DIRECTION AND IS NOW BEARISH");