相關標簽:
模型策略源碼://策略:Dual Thrust //類型:日內 //Designed By Rogarz //中間變量 input:n(1,1,100,1),K1(0.5,0.1,1,0.1),k2(0.5,0.1,1,0.1),nmin(10,1,100,1),ss(1,1,100,1),n1(70,1,100,1),n2(70,1,100,1); VARIABLE:fl=0; VARIABLE:該筆盈虧:=0;模擬持倉:=0,模擬開倉價:=0,模擬平倉價:=0,真實系統下單開關:=0; CYC:=barslast(date<>ref(date,1))+1; 昨高:=callstock(stklabel,vthigh,6,-1); 昨低:=callstock(stklabel,vtlow,6,-1); 昨收:=callstock(stklabel,vtclose,6,-1); 開盤價:=valuewhen(cyc=1,open); HH:=hhv(昨高,n);//N日high的最高價 HC:=hhv(昨收,n);//N日close的最高價 LC:=LLV(昨收,n);//N日close的最低價 LL:=LLV(昨低,n);//N日low的最低價 浮動區間:=max(HH-LL,HC-LL);//range 上軌:開盤價+k1*浮動區間; 下軌:開盤價-K2*浮動區間; t1:=time>opentime(1) and time<closetime(0)-nmin*100; t2:=time>=closetime(0)-nmin*100; 手數:=ss; //虧損5000后停止交易 r1:=barslast(day<>ref(day,1)); r2:=ref(asset,r1)-asset<3000; //交易條件 開多條件:=cross(c,上軌) and r2 and holding=0; 開空條件:=cross(下軌,c) and r2 and holding=0; 交易時間:=TIME>=091500 AND TIME<143000; //交易系統 m.kzuj.com.cn if 開多條件 then BEGIN 開多:buy(交易時間 and cyc>1,手數,market); fl:=0; end if 開空條件 then BEGIN 開空:buyshort(交易時間 and cyc>1,手數,market); fl:=0; end //止損 多頭止損條件:=c<enterprice-N1*mindiff and time<145500; 空頭止損條件:=c>enterprice+n2*mindiff and time<145500; if 多頭止損條件 and holding>0 then begin 多頭止損:sell(1,0,market); end if 空頭止損條件 and holding<0 then BEGIN 空頭止損:sellshort(1,0,market); end //止損和最大獲利后的回調止贏分三種點位止贏 en:=enterbars; //開倉歷來的周期數 enlv:=llv(l,en+1); //開倉以來的最低值 enhv:=hhv(h,en+1); //開倉以來的最高值 //設變量 持倉狀態下的最大盈利 win:=0; //最大獲利 m.kzuj.com.cn win2:=0; //最大獲利幅度 win3:=0; //最大獲利后的最大回調幅度 if holding > 0 and enterbars > 0 then begin win:=(enhv-enterprice); win2:=(enhv-enterprice)/enterprice*100; win3:=(enhv-c)/win*100; end if holding < 0 and enterbars > 0 then begin win:=(enterprice- enlv); win2:=(enterprice-enlv)/enterprice*100; win3:=(c-enlv)/win*100; end //出現最高盈利后,獲利10---25個點,按回撤70%止贏 If win>10 and win3>=70 then begin 多倉止贏2:SELL(openprofit > 0 and holding>0, 0); 空倉止贏2:SELLshort(openprofit > 0 and holding<0, 0); End If win>5 and fl<2 then begin 加多倉:buy(交易時間 ,手數,market); 加空倉:buyshort(交易時間,手數,market); fl:=fl+1; End //4K線出場 m.kzuj.com.cn sqsxd:=count(c>ref(c,1),3)=3 and count(c>=o,4)=4,linethick0;//做空時4K線出場 sqsxk:=count(c<ref(c,1),3)=3 and count(c<=o,4)=4; if sqsxk and win<10 and holding>0 then begin 多頭4K線出場:sell(1,0,market); end if sqsxd and win<10 and holding<0 then BEGIN 空頭4K線出場:sellshort(1,0,market); end if time>=144000 then BEGIN 收盤平多:sell(1,0,market); 收盤平空:sellshort(1,0,market); 交易次數:=0; fl:=0; end 點擊復制上述代碼粘貼到到公式管理器
{別忘了將本網告訴您身邊的朋友,向朋友傳達有用資料,也是一種人情,你朋友會感謝你的。}