def SMMA(column,N):
for i in range(len(column)):
if i <= N:
SMMA(i) = np.nan()
elif i == N + 1:
SMMA(i) = column[:N].mean()
else:
SMMA(i) = (SMMA(i-1)*N + column[i])/ N
Smoothed Moving Average (SMMA) is one of my favorite financial analysis tool.It is different from the well-know Simply moving Average tool. below is the definition and above is my code, but the IDE is kept telling me syntaxError:
File "<ipython-input-13-fdcc1fd914c0>", line 6
SMMA(i) = column[:N].mean()
^SyntaxError: can't assign to function call
Definition of SMMA:
The first value of this smoothed moving average is calculated as the simple moving average (SMA):
SUM1 = SUM (CLOSE (i), N)
SMMA1 = SUM1 / N
The second moving average is calculated according to this formula:
SMMA (i) = (SMMA1*(N-1) + CLOSE (i)) / N
Succeeding moving averages are calculated according to the below formula:
PREVSUM = SMMA (i - 1) * N
SMMA (i) = (PREVSUM - SMMA (i - 1) + CLOSE (i)) / N