'SMA(X,N,M)求X的N个周期内的移动平均。M为权重。
'计算方法:SMA(N)=SMA(N-1)*(N-M)/N+X(N)*M/N
'举例求rb01的日线收盘价的SMA
sub test()
code="rb01"
market="sq"
mode=5
set history=marketdata.GetHistoryData(code,market,mode)
N=5
M=2
sma=0
for i=0 to history.Count-1
sma=(sma*(N-M)+history.Close(i)*M)/N
next
msgbox sma
end sub