回复 62楼 sdta
正确,现在语句简单了。我在1a0001中加了字段trmd,trmd(nday)=(trma(nday)+2*trmd(nday-1))/3,作为kdj的d值
USE 1a0001.DBF ALIAS A
T1=seconds()
BLANK ALL FIELDS K,D,TRIX,TRMA,
trmd
G=100 &&此处设为100,否则nday开始的几条数据不正确
h=100
nday=9 &&修改天数
FOR I=1 TO RECCOUNT()-(nday-1)
SELECT SHHIGH,SHLOW FROM 1A0001 WHERE BETWEEN(RECNO(),I,I+(nday-1)) INTO ARRAY AA
=ACOPY(AA,BB)
=ASORT(BB,1) &&按SHHIGH排序
BB1=BB(nday,1) &&最大值
=ASORT(BB,2) &&按SHLOW排序
BB2=BB(1,2) &&最小值
SELECT A
REPLACE K WITH BB2,D WITH BB1,TRIX WITH (ABS(shclose-k)/ABS(d-k))*100,TRMA WITH (TRIX+2*G)/3 FOR RECNO()=I+(nday-1)
GO I+(nday-1)
G=TRMA &&trma列为kdj.k
repl TRMd WITH (TRma+2*h)/3 FOR RECNO()=I+(nday-1) &&增加了trmd列,为kdj.d 本想放上面的,但编译不通过,搞不懂,所以另写一行了
GO I+(nday-1)
h=trmd
ENDFOR
MESSAGEBOX("共用时间: "+TRANSFORM(seconds()-T1,"@Z 999.99")+" 秒")
BROWSE
通过,结果正确
[
本帖最后由 reedwu 于 2012-3-17 00:48 编辑 ]