回复 91楼 sdta
USE 1a0001.DBF ALIAS A
BLANK ALL FIELDS K,D,TRIX,TRMA,trmd
G=100
H=100
CREATE CURSOR LSB (XH N(3),NDAY N(2),NM N(2),NN N(2)) &&这段程序就是替代下面三行的参数,后面运行的程序是不改的,只要不断的把三个值让程序运行就好了
FOR NDAY1=9 TO 20
FOR NM1=3 TO 5
FOR NN1=3 TO 5
INSERT INTO LSB VALUES(RECNO(),NDAY1,NM1,NN1) &&这句执行时出错了
&nday=18
&&修改天数
&nm=5
&&修改k参数
&nn=4
&&修改d参数
FOR I=1 TO RECCOUNT()-(nday-1)
SELECT MAX(SHHIGH),MIN(SHLOW) FROM 1A0001 WHERE BETWEEN(RECNO(),I,I+(nday-1)) INTO ARRAY AA
SELECT A
REPLACE K WITH AA(1,2),D WITH AA(1,1),TRIX WITH (ABS(shclose-k)/ABS(d-k))*100,TRMA WITH (TRIX+(nm-1)*G)/nm,TRMD WITH (TRMA+(nn-1)*H)/nn FOR RECNO()=I+(nday-1)
GO I+(nday-1)
G=TRMA
H=TRMD
ENDFOR
&&Close all
*----KD表
SELECT *,CAST("" AS Numeric(4)) AS TRME FROM 1A0001 WHERE trma>trmd INTO TABLE KD
B=SHNO
SCAN FOR RECNO()>1 AND !EOF()
A=SHNO
REPLACE TRME WITH A-B
B=SHNO
ENDSCAN
DELETE FOR TRME=1
PACK
*----DK表
SELECT *,CAST("" AS Numeric(4)) AS TRME FROM 1A0001 WHERE trma<trmd INTO TABLE DK
B=SHNO
SCAN FOR RECNO()>1 AND !EOF()
A=SHNO
REPLACE TRME WITH A-B
B=SHNO
ENDSCAN
DELETE FOR TRME=1
PACK
&&Close all
SELECT shno,shtime,shy,shm,shhigh,shlow,shclose,trma,trmd,CAST("" AS Numeric(4)) AS TRMEKD,CAST("" AS Numeric(4)) AS TRMEDK, CAST("" AS Numeric(15,4)) AS profit FROM 1A0001 INTO TABLE KDDK
UPDATE KDDK SET TRMEKD=KD.TRME FROM KD WHERE KDDK.SHNO==KD.SHNO
UPDATE KDDK SET TRMEDK=DK.TRME FROM DK WHERE KDDK.SHNO==DK.SHNO
DELETE FOR (TRMEKD=0 AND TRMEDK=0) &&可以留着,这样数据都全
PACK
CLOSE TABLES
&&close all
USE kddk.dbf
GO TOP
b=shclose
SCAN FOR RECNO()>1 AND !EOF()
REPLACE profit WITH shclose-b
b=shclose
ENDSCAN
REPLACE ALL profit WITH 0 for trmekd>0
SELECT SUM(profit) FROM kddk WHERE shy>=2009
INTO ARRAY xx
?nday1,nm1,nn1,xx
ENDFOR
ENDFOR
ENDFOR
CLOSE TABLES
ERASE KD.DBF
ERASE DK.DBF
CLOSE ALL
[
本帖最后由 reedwu 于 2012-3-20 11:09 编辑 ]