回复 40楼 sdta
我在trma,trix第8列上都输了100,下面是完整的程序,我先计算出rsv值写入trix,再计算出k值写进trma,更新到k,再计算出d,现在要编的是提取每次发生k>d时的列,过滤掉中间数据,再把发生k<d时的列提炼出来,这是第一步,就能计算金叉和死叉的获利情况了,第二步是把在这k>d期间中间发生的高点shhigh的列和k<d期间的最低点shlow的列提出来,看看金叉买入到高点能获利多少,再看看死叉卖出到最低点能避免多少的亏损,当然第2步比较难,分析难度高了
CLOSE TABLES
USE 1a0001.DBF ALIAS A
&& BLANK ALL FIELDS K,D
FOR I=1 TO RECCOUNT()-8
SELECT SHHIGH,SHLOW FROM 1A0001 WHERE BETWEEN(RECNO(),I,I+8) INTO ARRAY AA
=ACOPY(AA,BB)
=ASORT(BB,1) &&按SHHIGH排序
BB1=BB(9,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 FOR RECNO()=I+8
ENDFOR
CLOSE ALL
USE 1a0001.DBF ALIAS A
n=9
GO n
DO WHILE !EOF()
rsv=((shclose-k)/(d-k))*100
REPLACE trix WITH rsv
SKIP
n=n+1
ENDDO
CLOSE ALL
&&sma测试通过
USE 1a0001.DBF ALIAS A
n=9
GO n
DO WHILE !EOF()
a=trix
GO n-1
b=trma
h=(a+2*b)/3
GO n
REPLACE trma WITH h
SKIP
n=n+1
ENDDO
CLOSE ALL
USE 1a0001.DBF ALIAS A
REPLACE ALL k WITH trma
n=9
GO n
DO WHILE !EOF()
a=k
GO n-1
b=d
h=(a+2*b)/3
GO n
REPLACE d WITH h
SKIP
n=n+1
ENDDO
CLOSE ALL
[
本帖最后由 reedwu 于 2012-3-16 16:43 编辑 ]