以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]反于反手与提前融合编写的问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=56982)

--  作者:利期
--  发布时间: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:09:00
--  

意思是策略既要反手又要有提前?

CC是启什么作用的?

[此贴子已经被作者于2013/9/25 11:10:32编辑过]

--  作者:利期
--  发布时间:2013/9/25 11:10:51
--  
是的,我改编只达到了反手效果,但提前作用没有做到。忙请帮修一个。
--  作者: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


--  作者:利期
--  发布时间:2013/9/25 11:45:49
--  

试测了一下,没成功啊。跟我改的不成功一样。还是相差一个周期,没达到提前作用。

 


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20130925114226.jpg
图片点击可在新窗口打开查看

这个是反手提前



图片点击可在新窗口打开查看此主题相关图片如下:qq图片20130925114205.jpg
图片点击可在新窗口打开查看
这个是提前。


--  作者:jinzhe
--  发布时间:2013/9/25 13:05:52
--  

提前是这个意思?那么这个是未来了