Smooth Moving Average AFL Needed

#1
Can someone provide me the AFL for a Smooth Moving Average? I have got the formula for the same over the internet but I am not able to convert it into an AFL.

Formula:CalculationThe first value of this smoothed moving average is calculated as the simple moving average (SMA) with the same period. The second and succeeding moving averages are calculated according to this formula:

PREVSUM = SMMA(i-1) *N
SMMA(i) = (PREVSUM-SMMA(i-1)+CLOSE(i))/N

Where: SUM1 is the total sum of closing prices for N periods;
PREVSUM is the smoothed sum of the previous bar;
SMMA1 is the smoothed moving average of the first bar;
SMMA(i) is the smoothed moving average of the current bar (except for the first one);
CLOSE(i) is the current closing price;
N is the smoothing period.

Thanks
 

KelvinHand

Well-Known Member
#2
Can someone provide me the AFL for a Smooth Moving Average? I have got the formula for the same over the internet but I am not able to convert it into an AFL.

Formula:CalculationThe first value of this smoothed moving average is calculated as the simple moving average (SMA) with the same period. The second and succeeding moving averages are calculated according to this formula:

PREVSUM = SMMA(i-1) *N
SMMA(i) = (PREVSUM-SMMA(i-1)+CLOSE(i))/N

Where: SUM1 is the total sum of closing prices for N periods;
PREVSUM is the smoothed sum of the previous bar;
SMMA1 is the smoothed moving average of the first bar;
SMMA(i) is the smoothed moving average of the current bar (except for the first one);
CLOSE(i) is the current closing price;
N is the smoothing period.

Thanks
Here the Smooth Moving Average similar to MT4.

Code:
MA_Period=Param("Period", 5, 1);

ssma = MA(C, MA_Period);

for(i=MA_Period+1; i<BarCount; i++)
{
   iSum = ssma[i-1]*(MA_Period-1)+Close[i];
   ssma[i] = iSum/MA_Period;
}

Plot(ssma, "SSMA", ParamColor("Color", colorRed), ParamStyle("Style"));
 

Similar threads