Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
SMA: procedure (N) returns (float byaddr);
|
||||
declare N fixed;
|
||||
declare A(*) fixed controlled,
|
||||
(p, q) fixed binary static initial (0);
|
||||
|
||||
if allocation(A) = 0 then signal error;
|
||||
|
||||
p = p + 1; if q < 20 then q = q + 1;
|
||||
if p > hbound(A, 1) then p = 1;
|
||||
A(p) = N;
|
||||
return (sum(float(A))/q);
|
||||
|
||||
I: ENTRY (Period);
|
||||
declare Period fixed binary;
|
||||
|
||||
if allocation(A) > 0 then FREE A;
|
||||
allocate A(Period);
|
||||
A = 0;
|
||||
p = 0;
|
||||
end SMA;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
*process source attributes xref;
|
||||
mat: Proc Options(main);
|
||||
Dcl a(10) Dec Fixed(8,6);
|
||||
Dcl s Dec Fixed(10,8);
|
||||
Dcl n Bin Fixed(31) init(hbound(a)); /* number of items in the list. */
|
||||
Dcl p Bin Fixed(31) init(3); /* the 1st period */
|
||||
Dcl q Bin Fixed(31) init(5); /* the 2nd period */
|
||||
Dcl m Bin Fixed(31);
|
||||
Call i(a);
|
||||
|
||||
Put Edit(' SMA with SMA with',
|
||||
' number period 3 period 5',
|
||||
' -------- ---------- ----------')
|
||||
(Skip,a);
|
||||
Do m=1 To n;
|
||||
Put Edit(m,sma(p,m),sma(q,m))(Skip,f(5),2(f(13,6)));
|
||||
End;
|
||||
|
||||
i: Proc(a);
|
||||
Dcl a(*) Dec Fixed(8,6);
|
||||
Dcl (j,m) Bin Fixed(31);
|
||||
Do j=1 To hbound(a)/2;
|
||||
a(j)=j; /* ··· increasing values. */
|
||||
End;
|
||||
Do k=hbound(a)/2 To 1 By -1;
|
||||
a(j)=k; /* ··· decreasing values. */
|
||||
j+=1;
|
||||
End;
|
||||
End;
|
||||
|
||||
sma: Proc(p,j) Returns(Dec Fixed(8,6));
|
||||
Dcl s Dec fixed(8,6) Init(0);
|
||||
Dcl i Bin Fixed(31) Init(0);
|
||||
Dcl j Bin Fixed(31) Init((hbound(a)+1));
|
||||
Dcl (p,i,k,ka,kb) Bin Fixed(31);
|
||||
ka=max(1,j-p+1);
|
||||
kb=j+p;
|
||||
Do k=ka To kb While(k<=j);
|
||||
i+=1;
|
||||
s+=a(k)
|
||||
End;
|
||||
s=s/i+0.5e-6;
|
||||
Return(s);
|
||||
End;
|
||||
End;
|
||||
Loading…
Add table
Add a link
Reference in a new issue