Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
data 1,2,3,4,5,5,4,3,2,1
|
||||
dim sd(10) ' series data
|
||||
global sd ' make it global so we all see it
|
||||
for i = 1 to 10:read sd(i): next i
|
||||
|
||||
x = sma(3) ' simple moving average for 3 periods
|
||||
x = sma(5) ' simple moving average for 5 periods
|
||||
|
||||
function sma(p) ' the simple moving average function
|
||||
print "----- SMA:";p;" -----"
|
||||
for i = 1 to 10
|
||||
sumSd = 0
|
||||
for j = max((i - p) + 1,1) to i
|
||||
sumSd = sumSd + sd(j) ' sum series data for the period
|
||||
next j
|
||||
if p > i then p1 = i else p1 = p
|
||||
print sd(i);" sma:";p;" ";sumSd / p1
|
||||
next i
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue