老師;請教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點的二次止盈就沒啥用了。