if barpos <= Cyc then exit;//不到CYC的统计周期,直接退出等待下个周期再做判断 if barpos = cyc+1 then begin af:=Step; ep:=-1; if (high[barpos]-high[barpos-1])+(low[barpos]-low[barpos-1]) > 0 then begin //看跌 TrendFlag:= -1; sarx:=highprice; end else begin //看涨 TrendFlag:= 1; sarx:=lowPrice; end GOTO ENDANDSHOW;//跳转到末尾直接显示 End //判断出这些日子数据的上涨,或者下跌 if TrendFlag > 0 then begin //是否为跳转标志 if ep > 0 then begin sarx:=lowPrice; EP:=-1; GOTO ENDANDSHOW;//跳转到末尾直接显示 end
//如果今日最高价大于前N的最高价,加速因子需要增加 if high > highprice then begin af := af+step; if af > fmax then af := fmax; end
fsar := sarx + af * (highprice - sarx); //是否跳转 if fsar > low then begin TrendFlag:=-1; ep:=1; af:=step; end sarx:=fsar; end else begin if ep > 0 then begin sarx:=highprice; ep:=-1; GOTO ENDANDSHOW; //跳转到末尾直接显示 end
//看跌 if low < lowPrice then begin af := af + step; if af > fmax then af := fmax; end
fsar := sarx + af * (lowprice-sarx);
//是否跳转 if fSar < High then begin TrendFlag := 1; EP := 1; AF := Step; end sarx := fSar; end //显示变量 ENDANDSHOW@; //此为语句标号,GOGO语句可以用这个标号直接跳转到这里 ShowSar:sarx;