trix129.rar
(197.68 KB)
&&Close all SELECT shno,shtime,shy,shhigh,shlow,shclose,trix,trma,CAST("" AS Numeric(4)) AS TRMEKD,CAST("" AS Numeric(4)) AS TRMEDK, CAST("" AS Numeric(15,4)) AS profit FROM 1A0001 INTO TABLE VTRIX
UPDATE VTRIX SET TRMEKD=KD.TRME FROM KD WHERE VTRIX.SHNO==KD.SHNO
UPDATE VTRIX SET TRMEDK=DK.TRME FROM DK WHERE VTRIX.SHNO==DK.SHNO
&&DELETE FOR (TRMEKD=0 AND TRMEDK=0) &&detail 把这句去掉能得到全部数据,如附件的excel,但怎样能取值出红字部分,生成新表,请高手们指教
SELECT * FROM vtrix WHERE TRMEKD<>0 or TRMEDK<>0 INTO TABLE vtrix1 &&生成DELETE FOR (TRMEKD=0 AND TRMEDK=0)的表vtrix1,只包括了金叉死叉的数据
现在就是分别取出2张表里的数据,取vtrix1中第1行的shclose做为买入价,取vtrix1表中第2行的shclose做为卖出价,shno分别是75,87 ,(也可以直接用kd、dk表的数据)
,然后在vtrix表里取出shno是76到87的shhigh中最大值,和shlow中的最小值,生成一张新的表。然后是从vtrix1的第三行再重复上面的
USE vtrix1.dbf
n=2
GO n
DO WHILE !EOF()
a=shno
c=shclose
e=trmedk
h=profit
GO n-1
b=shno
d=shclose
f=shtime
g=shy
SELECT MAX(SHHIGH),MIN(SHLOW) FROM trix WHERE BETWEEN(RECNO(),b+1,a) INTO ARRAY AA
INSERT INTO vtrix2(shno,shtime,shy,shhigh,shlow,shclose,shopen,trmedk,profit) values(b,f,g,aa(1,1),aa(1,2),c,d,e,h)
&&只能插入第1条记录,第2条报错了(field shhigh does not accept null values)
SKIP&& 到这里程序好像把vtrix1.dbf关闭了
n=n+2
ENDDO
CLOSE ALL
[ 本帖最后由 reedwu 于 2012-4-1 10:06 编辑 ]