VARIABLE:up[4]=0;
up[1]:=ma(c,5)-c;
up[2]:=ma(c,10)-c;
up[3]:=ma(c,15)-c;
up[4]:=ma(c,20)-c;
temp1:=0;
mark1:=0;
temp2:=0;
mark2:=0;
for i=1 to 4 do
begin
if up[i]>0 then //等于0则忽略
begin
if up[i]<=temp1 or temp1=0 then begin temp1:=up[i]; mark1:=i;end
end
if up[i]<0 then
begin
if up[i]>=temp2 or temp2=0 then begin temp2:=up[i];mark2:=i;end
end
end
z:mark1;//获取的是上方均线的下标值,下标顺序对应从5日到20日
q:mark2;//获取的是下方均线的下标值
你别搞太多K,会崩溃的。这里循环次数不多,就四次。你K线多了,那就不能保证了。