相關標簽:惠比特交易和配種專區,夢三國交易專區,夢三國交易專區速秒,靈緹格力交易專區,中京交易市場下載專區,古幣銀元交易專區,長毛德牧交易專區,夢三國交易專區在哪里,qq交易專區,
模型策略源碼:runmode:0; input:riskratio(1,0,2,1); input:atrlength(20,5,40,5); input:period1(20,5,60,5); input:period2(55,5,60,5); input:period3(10,5,60,5); variable:times:=0; if barpos=1 then begin preenteryprice:=0; prebreakoutfailure:=false; end if barpos<=period1 then exit; if date<1110104 then exit; begin if stricmp(marketlabel,\'sq\')=0 then label:=strleft(stklabel,2); if stricmp(marketlabel,\'dq\')=0 then label:=strleft(stklabel,1); if stricmp(marketlabel,\'zq\')=0 then label:=strleft(stklabel,2); if stricmp(marketlabel,\'zj\')=0 then label:=strleft(stklabel,2); if stricmp(label,\'cf\')=0 then begin marginratio:=0.17; commission:=12; tradeable:=true; end if not(tradeable) then exit; end begin atr:=trimprice(ref(ma(tr,atrlength),1)); topband1:=ref(hhv(high,period1),1)+mindiff; botband1:=ref(llv(low,period1),1)-mindiff; topband2:=ref(hhv(high,period2),1)+mindiff; botband2:=ref(llv(low,period2),1)-mindiff; topband3:=ref(hhv(high,period3),1)+mindiff; botband3:=ref(llv(low,period3),1)-mindiff; enterlongcond1:=high>=topband1; enterlongprice1:=max(open,topband1); entershortcond1:=low<=botband1; entershortprice1:=min(open,botband1); enterlongcond2:=high>=topband2; enterlongprice2:=max(open,topband2); entershortcond2:=low<=botband2; entershortprice2:=min(open,botband2); exitlongcond:=low<=botband3; exitlongprice:=min(open,botband3); exitshortcond:=high>=topband3; exitshortprice:=max(open,topband3); end if holding=0 then begin price:=0; lots:=0; if enterlongcond1 and prebreakoutfailure then price:=enterlongprice1; if enterlongcond2 then price:=enterlongprice2; if price>0 then begin mycash:=cash(0); lots1:=intpart(mycash/(price*multiplier*marginratio)); if riskratio=0 then begin lots:=lots1; end else begin lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then begin buy(1,lots,limitr,price); times:=1; prebreakoutfailure:=false; end end if holding=0 then begin price:=0; lots:=0; if entershortcond1 and prebreakoutfailure then price:=entershortprice1; if entershortcond2 then price:=entershortprice2; if price>0 then begin mycash:=cash(0); lots1:=intpart(mycash/(price*multiplier*marginratio)); if riskratio=0 then begin lots:=lots1; end else begin lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then begin buyshort(1,lots,limitr,price); times:=1; prebreakoutfailure:=false; end end if holding>0 then begin while high>=enterprice+0.5*atr and times<=4 do begin price:=max(open,enterprice+0.5*atr); lots:=0; if price>0 then begin mycash:=cash(0); lots1:=intpart(mycash/(price*multiplier*marginratio)); if riskratio=0 then begin lots:=lots1; end else begin lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then begin buy(1,lots,limitr,price); times:=times+1; end end price:=0; if exitlongcond then price:=exitlongprice; if low<=enterprice-2*atr and enterbars<>0 then begin price:=min(open,enterprice-2*atr); prebreakoutfailure:=true; end if price>0 then sell(1,holding,limitr,price); end if holding<0 then begin while low<=enterprice-0.5*atr and times<=4 do begin price:=min(open,enterprice-0.5*atr); lots:=0; if price>0 then begin mycash:=cash(0); lots1:=intpart(mycash/(price*multiplier*marginratio)); if riskratio=0 then begin lots:=lots1; end else begin lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then begin buyshort(1,lots,limitr,price); times:=times+1; end end price:=0; if exitshortcond then price:=exitshortprice; if high>=enterprice+2*atr and enterbars<>0 then begin price:=max(open,enterprice+2*atr); prebreakoutfailure:=true; end if price>0 then sellshort(1,holding,limitr,price); end 點擊復制上述代碼粘貼到到公式管理器
{別忘了將本網告訴您身邊的朋友,向朋友傳達有用資料,也是一種人情,你朋友會感謝你的。}