INPUT:手数(1,1,10000,1);
INPUT:止损(50,1,100,1);
INPUT:回撤(5,1,10,1);
variable:开仓次数=0;
横盘高点:=ref(hhv(h,20),1);
横盘低点:=ref(llv(l,20),1);
多头止损价:=enterprice-止损*mindiff,noaxis;
空头止损价:=enterprice+止损*mindiff,noaxis;
开仓后最高:=hhv(h,enterbars+1),noaxis;
开仓后最低:=llv(l,enterbars+1),noaxis;
开多仓后最高盈利:=开仓后最高-enterprice,noaxis;
开空仓后最高盈利:=enterprice-开仓后最低,noaxis;
多仓当前盈利:=c-enterprice,noaxis;
空仓当前盈利:=enterprice-c,noaxis;
开仓时间:=time>090000 and time<=143000;
收盘平仓时间:=time>145500;
//进场的条件
开多条件:=ref(c,1)>横盘高点 and todaybar>=30 and 开仓时间 and 开仓次数<=4 and holding=0;
开空条件:=ref(c,1)<横盘低点 and todaybar>=30 and 开仓时间 and 开仓次数<=4 and holding=0 ;
//止盈平仓
if holding>0 and 开多仓后最高盈利>=50*mindiff and 多仓当前盈利<=(回撤/10)*开多仓后最高盈利 and enterbars>0 then begin
止盈平多:sell(1,holding,market);
开仓次数:=开仓次数+1;
end;
if holding<0 and 开空仓后最高盈利>=50*mindiff and 空仓当前盈利<=(回撤/10)*开空仓后最高盈利 and enterbars>0 then begin
止盈平空:sellshort(1,holding,market);
开仓次数:=开仓次数+1;
end
//止损平仓
if holding>0 and l<=多头止损价 then begin
止损平多:sell(1,holding,market);
开仓次数:=开仓次数+1;
end;
if holding<0 and h>=空头止损价 then begin
止损平空:sell(1,holding,market);
开仓次数:=开仓次数+1;
end;
//开仓
if 开空条件=1 then begin
开空:buyshort(开空条件,手数,limitr,o);
开仓次数:=开仓次数+1;
end;
if 开多条件=1 then begin
开多:buy(开多条件,手数,limitr,o);
开仓次数:=开仓次数+1;
end
//收盘平仓
if 收盘平仓时间 and holding<>0 then begin
平多:sell(1,holding,limitr,o);
平空:sellshort(1,holding,limitr,o);
开仓次数:=0;
end
改成2个周期前就有信号了。
横盘高点:ref(hhv(h,20),2);
横盘低点:ref(llv(l,20),2);
麻烦老师给检查一下,指令排列是不是有问题,在股指期货上信号不出现得不好,只是有少量的信号,我改了参数,其他有些期货也不出信号,我编这个程序,主要是想学习一下指令的编排顺序