以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请高手帮忙!  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=51074)

--  作者:123abc
--  发布时间:2013/4/16 9:57:35
--  请高手帮忙!

runmode:0;
variable:cc=0;
islast:=islastbar;
bb:=c>o+0.6;
ss:=c<o-0.6;
if cc>0 and ss then cc:=0;
if cc<0 and bb then cc:=0;
if cc=0 and bb then cc:=1;
if cc=0 and ss then cc:=-1;
lcc:=ref(cc,1);
if islast then att:=extgbdata(\'att\');

if (lcc>0 and cc<=0) or (islast and cc<=0 and barpos>att and tbuyholding(1)>0) then begin
 exitlong:1;
 if lcc>0 and cc<=0 and islast then extgbdataset(\'att\',barpos);
end
if (lcc<0 and cc>=0) or (islast and cc>=0 and barpos>att and tsellholding(1)>0) then begin
 exitshort:1;
 if lcc<0 and cc>=0 and islast then extgbdataset(\'att\',barpos);
end
if (lcc<=0 and cc>0) or (islast and cc>0 and barpos>att and tbuyholding(1)=0) then begin
 enterlong:1;
 if lcc<=0 and cc>0 and islast then extgbdataset(\'att\',barpos);
end
if (lcc>=0 and cc<0) or (islast and cc<0 and barpos>att and tsellholding(1)=0) then begin
 entershort:1;
 if lcc>=0 and cc<0 and islast then extgbdataset(\'att\',barpos);
end

 

 

帮忙改成K线走完提前N秒下单信号消失次周期恢复持仓!

这是阿火的,及时下单信号消失次周期恢复吃仓!

 

帮忙修改!谢谢!

 

 


--  作者:jinzhe
--  发布时间:2013/4/16 10:11:54
--  

zq:=2;//周期类型,2分钟就填2,3分钟就填3 ,5分钟就填5,10分钟就填10
tq:=5;//提前的秒数,最多提前60秒
lastopentm:=if(date<>ref(date,1),0,ref(openminutes(time),1));//上一根K线的开盘分钟数
ticktm:=dynainfo(207);
abb:=(mod(ticktm,100)>=60-tq and (openminutes(ticktm)-lastopentm=zq-1 or (ticktm>=112900 and ticktm<=113000) or (ticktm>=151400 and ticktm<=151500))) or not(islastbar);

 

平仓条件加上ABB


--  作者:123abc
--  发布时间:2013/4/16 10:21:34
--  

开仓条件不加上ABB?

在K线走完模式,开仓和平仓都要提前N秒下单,并在信号消失后次周期恢复持仓!

 


--  作者:123abc
--  发布时间:2013/4/16 10:27:03
--  

我要的效果是:

在K线走完模式,开仓和平仓都要提前N秒下单,并在信号消失后次周期恢复持仓!

 


--  作者:jinzhe
--  发布时间:2013/4/16 10:37:33
--  
那全加上不就得了
--  作者:123abc
--  发布时间:2013/4/16 11:30:42
--  

信号消失次周期不恢复持仓?

 


--  作者:123abc
--  发布时间:2013/4/16 13:25:29
--  

顶!


--  作者:jinzhe
--  发布时间:2013/4/16 13:38:32
--  
完整代码贴一下
--  作者:123abc
--  发布时间:2013/4/16 13:45:15
--  

runmode:0;
 
input:n1(4,1,100,1);
input:n2(9,1,100,1);
input:n3(18,1,100,1);
 
ma1:=ma(close,n1);
ma2:=ma(close,n2);
ma3:=ma(close,n3);


zq:=2;//周期类型,2分钟就填2,3分钟就填3 ,5分钟就填5,10分钟就填10
tq:=5;//提前的秒数,最多提前60秒
lastopentm:=if(date<>ref(date,1),0,ref(openminutes(time),1));//上一根K线的开盘分钟数
ticktm:=dynainfo(207);
abb:=(mod(ticktm,100)>=60-tq and (openminutes(ticktm)-lastopentm=zq-1 or (ticktm>=112900 and ticktm<=113000) or (ticktm>=151400 and ticktm<=151500))) or not(islastbar);

 

 

 


if holding=0 then begin
     if close>ma1 and ma1>ma2 and ma2>ma3 and abb then
         buy(1,1,limitr,close);
end
 
if holding=0 then begin
    if close<ma1 and ma1<ma2 and ma2<ma3 and abb then
        buyshort(1,1,limitr,close);
end

if holding>0 and abb then begin
     if ma1<ma2 then
         sell(1,holding,limitr,close);
end
 
if holding<0 and abb  then begin
     if ma1>ma2 then
         sellshort(1,holding,limitr,close);
end


--  作者:jinzhe
--  发布时间:2013/4/16 14:00:46
--  

不能用图表,用后台