相关标签:
模型策略源码://策略: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; //交易系统 www.cxh99.com 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; //最大获利 www.cxh99.com 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线出场 WWW.CXH99.COM 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 点击复制上述代码粘贴到到公式管理器
{别忘了将本网告诉您身边的朋友,向朋友传达有用资料,也是一种人情,你朋友会感谢你的。}