把ema放while外面
VARIABLE: i=0,x=0,y=0.2; //y為當前品種最小的變動價位,今日值>昨日值x=-1,否則x=1,
c0:= c;
c1:= ema(c0,5);
c2:= ref(c1,1);
if c1>c2 then x:=-1; //x為-1,c1上升中,需遞減找到轉折點價格
if c1<c2 then x:=1; //x=1,c1處于下降中,需要滴增找到轉折點價格
s:ema(c0,5);
while x=-1 and c1>c2 do begin
i:=i+1;
c0:=c+y*x*i;
c1:=s;
end
while x=1 and c1<c2 do begin
i:=i+1;
c0:=c+y*x*i;
c1:=s;
end
mm: x;
VARIABLE: i=0,x=0,y=0.2; //y為當前品種最小的變動價位,今日值>昨日值x=-1,否則x=1,
c0:= c;
c1:= ema(c0,5);
c2:= ref(c1,1);
if c1>c2 then x:=-1; //x為-1,c1上升中,需遞減找到轉折點價格
if c1<c2 then x:=1; //x=1,c1處于下降中,需要滴增找到轉折點價格
if x=-1 and c1>c2 then begin
i:=i+1;
c0:=c+y*x*i;
c1:=c1;
end
if x=1 and c1<c2 then begin
i:=i+1;
c0:=c+y*x*i;
c1:=c1;
end
mm: x;