-- 跨周期优化时结果一模一样
老师好。用下面这个公式,做股票策略优化时。输出的结果都是一模一样的。优化的时候步差也够大的。请老师们帮忙修改一下,谢谢
VARIABLE:a:=0;
sa1:=STKINDI(\'\',\'aaa1.aa\',0,8);
sa2:=STKINDI(\'\',\'aaa1.aa1\',0,8);
sa3:=STKINDI(\'\',\'aaa1.aa2\',0,8);
sa4:=STKINDI(\'\',\'aaa1.aa3\',0,8);
sa5:=STKINDI(\'\',\'aaa1.aa4\',0,8);
sa12:=STKINDI(\'\',\'aaa1.aa\',0,7);
sa22:=STKINDI(\'\',\'aaa1.aa1\',0,7);
sa32:=STKINDI(\'\',\'aaa1.aa2\',0,7);
sa42:=STKINDI(\'\',\'aaa1.aa3\',0,7);
sa52:=STKINDI(\'\',\'aaa1.aa4\',0,7);
sas:=sa1>sa2 and sa2>sa3 and sa3>sa4 and sa4>sa5;
sas2:=sa12>sa22 and sa22>sa32 and sa32>sa42 and sa42>sa52;
sb1:=STKINDI(\'\',\'aaa2.aa\',0,8);
sb2:=STKINDI(\'\',\'aaa2.aa1\',0,8);
sb3:=STKINDI(\'\',\'aaa2.aa2\',0,8);
sb4:=STKINDI(\'\',\'aaa2.aa3\',0,8);
sb5:=STKINDI(\'\',\'aaa2.aa4\',0,8);
sb12:=STKINDI(\'\',\'aaa2.aa\',0,7);
sb22:=STKINDI(\'\',\'aaa2.aa1\',0,7);
sb32:=STKINDI(\'\',\'aaa2.aa2\',0,7);
sb42:=STKINDI(\'\',\'aaa2.aa3\',0,7);
sb52:=STKINDI(\'\',\'aaa2.aa4\',0,7);
sbs:=sb1>sb2 and sb2>sb3 and sb3>sb4 and sb4>sb5;
sbs2:=sb12>sb22 and sb22>sb32 and sb32>sb42 and sb42>sb52;
sc1:=STKINDI(\'\',\'aaa3.GL(Q,W,R,M,P)\',0,7);
sc2:=STKINDI(\'\',\'aaa3.GL\',0,6);
sc3:=sum(sc2,5)>0;
开多平空条件:=WEEKDAY>2 and sc1 and sc3 and sbs and sbs2 and sas and sas2;
开空平多条件:=c<ma(c,30) ;
SELL(开空平多条件 AND HOLDING>0,HOLDING,MARKET);
if 开多平空条件 AND HOLDING=0 then
begin
buy(1,1,MARKET);
n:=close;
end
下面是被引用的公式
新建公式 命名为aaa1,代码如下:
aa:ma(c,30);
aa1:ma(c,60);
aa2:ma(c,90);
aa3:ma(c,120);
aa4:ma(c,250);
新建公式 命名为aaa2,代码如下:
aa:ma(v,30);
aa1:ma(v,60);
aa2:ma(v,90);
aa3:ma(v,120);
aa4:ma(v,250);
新建公式 命名为aaa3,代码如下:
AA:=CROSS( C, REF(HHV(C,Q),1) ) AND C>=HHV(C,W) ;
TJ1:=COUNT(AA,20)<=4 AND C=HHV(C,R) AND BARSLAST(L=LLV(L,M))>P;
TJ2:=TJ1 AND NOT(REF(TJ1,1));
GL:COUNT(TJ2,60)<=5 AND TJ2;