老师;请教1个模型的编写:交易周期15分钟周期,交易手数:2手,每天开仓只一次。交易思路:在每天开盘半小时后,接下来超过前半小时最高价1个点做多,低于前半小时最低价1个点做空。止损都是15个点。盈利脱离开仓价15个点止损就调到开仓价。盈利高过开仓价30点,止盈1手,超过70点止盈另1手,没到止损 止盈价,就以收盘前1分钟的收盘价平仓。谢谢老师!
input:n(2,1,100);
variable:n1=0;//计算次数
zuigao:valuewhen(time<=094500,hhv(h,todaybar));//前半个小时最高价
zuidi:valuewhen(time<=094500,llv(l,todaybar));//前半个小时最高价
if h>zuigao and todaybar>2 and n1=0 and time<151500 then begin
buy(holding=0,1,market);
n1:=1;
end
if l<zuidi and todaybar>2 and n1=0 and time<151500 then begin
buyshort(holding=0,1,market);
n1:=1;
end
if c-enterprice>=15*mindiff and holding<0 then sellshort(holding<0,0,market);
if enterprice-c>=15*mindiff and holding>0 then sell(holding>0,0,market);//止损
if c-enterprice>=30*mindiff and holding>0 then sell(holding>0,0,market);
if enterprice-c>=30*mindiff and holding<0 then sellshort(holding<0,0,market);//止盈
if time>=151500 then begin
sell(holding>0,0,market);
sellshort(holding<0,0,market);
n1:=0;
end
if datatype<>3 then exit;
1盈利脱离开仓价15个点止损就调到开仓价,这句不懂
2一天只开一手仓,那么70点的二次止盈就没啥用了。
input:n(2,1,100);
variable:n1=0,n2=0;//计算次数
variable:yingli=0;
zuigao:valuewhen(time<=094500,hhv(h,todaybar));//前半个小时最高价
zuidi:valuewhen(time<=094500,llv(l,todaybar));//前半个小时最高价
if h>zuigao and todaybar>2 and n1=0 and time<151500 and holding=0 then begin
buy(holding=0,1,market);
yingli:=c-enterprice;
n1:=1;
end
if c-enterprice>yingli then yingli:=c-enterprice;
if l<zuidi and todaybar>2 and n2=0 and time<151500 and holding=0 then begin
buyshort(holding=0,1,market);
n2:=1;
yingli:=enterprice-c;
end
if enterprice-c>yingli then yingli:=enterprice;
if c-enterprice>=15*mindiff and holding<0 then sellshort(holding<0,0,market);
if enterprice-c>=15*mindiff and holding>0 then sell(holding>0,0,market);//止损
if yingli>15*mindiff and c<enterprice then sell(holding>0,0,market);
if yingli>15*mindiff and c>enterprice then sellshort(holding<0,0,market);//盈利15点后的止损
if c-enterprice>=30*mindiff and holding>0 then sell(holding>0,0,market);
if enterprice-c>=30*mindiff and holding<0 then sellshort(holding<0,0,market);//止盈
if c-enterprice>=70*mindiff and holding>0 then sell(holding>0,0,market);
if enterprice-c>=70*mindiff and holding<0 then sellshort(holding<0,0,market);//二次止盈
if time>=151500 then begin
sell(holding>0,0,market);
sellshort(holding<0,0,market);
n1:=0;
n2:=0;
end
if datatype<>3 then exit;