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秒下单信号消失次周期恢复持仓!
这是阿火的,及时下单信号消失次周期恢复吃仓!
帮忙修改!谢谢!
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
开仓条件不加上ABB?
在K线走完模式,开仓和平仓都要提前N秒下单,并在信号消失后次周期恢复持仓!
我要的效果是:
在K线走完模式,开仓和平仓都要提前N秒下单,并在信号消失后次周期恢复持仓!
信号消失次周期不恢复持仓?
顶!
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
不能用图表,用后台