-- 作者:利期
-- 发布时间:2013/9/25 10:51:35
-- [求助]反于反手与提前融合编写的问题
我改编的只能达到反手作用,只在次周期开盘价起价格作用。提前策略失效。反手策略与提前策略如何改编才能使得系统同时达到这两种功能?
这是反手策略
runmode:0;
input:cw(1,1,10,1);
variable:cc=0;
趋势1:EMA((EMA(CLOSE,5)+EMA(CLOSE,10)+EMA(CLOSE,15)+EMA (CLOSE,24))/4,2),COLORFF6AB5,LINETHICK2; 趋势2:EMA(((SLOPE(C,25)*20)+C),50),COLORFFFFFF,LINETHICK2;
开多平空条件:=CROSS(趋势1,趋势2); 开空平多条件:=CROSS(趋势2,趋势1);
entertime:=time>091600 and time<151300;
if holding>0 and cc<=0 then sell(1,cw,limitr,o);
if holding<0 and cc>=0 then sellshort(1,cw,limitr,o);
//此方法撤单和追单时间要控制在出信号的K线时间以内
if holding=0 and cc>0 and cw+tholding2>=cw then buy(1,cw,limitr,o);//平空成交后,"cw+tholding2>=cw "才会成立并开多
if holding=0 and cc<0 and cw-tholding2>=cw then buyshort(1,cw,limitr,o);//平多成交后,"cw-tholding2>=cw "才会成立并开空
if cc>0 and 开空平多条件 then cc:=0;
if cc<0 and 开多平空条件 then cc:=0;
if cc=0 and 开多平空条件 and entertime then cc:=1;
if cc=0 and 开空平多条件 and entertime then cc:=-1;
if time>=151300 then begin
cc:=0;
end
这是提前策略
趋势1:EMA((EMA(CLOSE,5)+EMA(CLOSE,10)+EMA(CLOSE,15)+EMA (CLOSE,24))/4,2),COLORFF6AB5,LINETHICK2; 趋势2:EMA(((SLOPE(C,25)*20)+C),50),COLORFFFFFF,LINETHICK2;
开多平空条件:=CROSS(趋势1,趋势2) AND TIME>091600 AND TIME<151300;//开多平空条件 开空平多条件:=CROSS(趋势2,趋势1) AND TIME>091600 AND TIME<151300;//开空平多条件
input:tq(3,3,60,1); abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar);
if abb then begin if holding>0 and 开空平多条件 then sell(1,1,thisclose),TFILTER; if holding<0 and 开多平空条件 then sellshort(1,1,thisclose),TFILTER; if holding=0 and 开多平空条件 then buy(1,1,thisclose),TFILTER; if holding=0 and 开空平多条件 then buyshort(1,1,thisclose),TFILTER;
end
|
-- 作者:jinzhe
-- 发布时间:2013/9/25 11:20:33
--
不明白cc是干什么用的,但是根据语法做了修改
趋势1:EMA((EMA(CLOSE,5)+EMA(CLOSE,10)+EMA(CLOSE,15)+EMA (CLOSE,24))/4,2),COLORFF6AB5,LINETHICK2; 趋势2:EMA(((SLOPE(C,25)*20)+C),50),COLORFFFFFF,LINETHICK2;
开多平空条件:=CROSS(趋势1,趋势2) AND TIME>091600 AND TIME<151300;//开多平空条件 开空平多条件:=CROSS(趋势2,趋势1) AND TIME>091600 AND TIME<151300;//开空平多条件
input:tq(3,3,60,1); abb:=(islastbar and time0-timetot0(dynainfo(207))<=tq) or not(islastbar); variable:cc=0;
entertime:=time>091600 and time<151300;
if holding>0 and cc<=0 and abb then sell(1,cw,limitr,o);
if holding<0 and cc>=0 and abb then sellshort(1,cw,limitr,o);
//此方法撤单和追单时间要控制在出信号的K线时间以内
if holding=0 and cc>0 and cw+tholding2>=cw and abb then buy(1,cw,limitr,o);//平空成交后,"cw+tholding2>=cw "才会成立并开多
if holding=0 and cc<0 and cw-tholding2>=cw and abb then buyshort(1,cw,limitr,o);//平多成交后,"cw-tholding2>=cw "才会成立并开空
if cc>0 and 开空平多条件 then cc:=0;
if cc<0 and 开多平空条件 then cc:=0;
if cc=0 and 开多平空条件 and entertime then cc:=1;
if cc=0 and 开空平多条件 and entertime then cc:=-1;
if time>=151300 then begin
cc:=0;
end
|