相關標簽:nfs系統腳本詳解,惠比特交易和配種專區,夢三國交易專區,夢三國交易專區速秒,靈緹格力交易專區,中京交易市場下載專區,古幣銀元交易專區,長毛德牧交易專區,夢三國交易專區在哪里,
模型策略源碼:runmode:0; input:entryperiod(1,1,5,1); input:initialstop(3,2,4,1); input:breakevenstop(4,2,4,1); input:trailingstop(5,4,8,1); input:exitperiod(2,1,5,1); input:intraday(1,0,1,1); input:money(0,0,10,1); input:offset(0,0,2,1); input:debug(0,0,1,1); variable:costprice=0; variable:stopline=0; variable:myasset=30000; 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,\'if\')=0 then begin marginratio:=15/100; commission:=0.6/10000; tradeable:=1; entrytime:=time>=093100 and time<=151400; exittime:=time>=151500; stoplossunit:=25*mindiff; length:=60; end else begin if stricmp(label,\'cf\')=0 then begin marginratio:=17/100; commission:=12; tradeable:=1; end if stricmp(label,\'sr\')=0 then begin marginratio:=18/100; commission:=6; tradeable:=1; end entrytime:=time>=091600 and time<=145900; exittime:=time>=150000; stoplossunit:=5*mindiff; length:=225; end end if tradeable=0 then exit; if not(datatype=1) then exit; begin cond:=date>ref(date,1) or barpos=1; dist:=barpos-valuewhen(cond,barpos)+1; averageprice:=trimprice(sum(amount,dist)/sum(vol,dist)/multiplier); settlementprice:=trimprice(sum(amount,length)/sum(vol,length)/multiplier); entryupperband:=ref(hhv(high,60*entryperiod),1)+mindiff; entrylowerband:=ref(llv(low,60*entryperiod),1)-mindiff; exitupperband:=ref(hhv(high,30*exitperiod),2)+mindiff; exitlowerband:=ref(llv(low,30*exitperiod),2)-mindiff; initialstopnum:=stoplossunit*initialstop; breakevenstopnum:=stoplossunit*breakevenstop; trailingstopnum:=stoplossunit*trailingstop; offsetnum:=mindiff*offset; end if holding=0 then begin myentryprice:=0; lots:=0; if year>=2011 and entrytime and high>=entryupperband then myentryprice:=max(open,entryupperband); if myentryprice>0 then begin mycash:=cash(0); if money=0 then begin lots:=1; end else begin lots1:=intpart(mycash/(myentryprice*multiplier*marginratio)); lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then buy(1,lots,limitr,myentryprice+offsetnum); end if holding=0 then begin myentryprice:=0; lots:=0; if year>=2011 and entrytime and low<=entrylowerband then myentryprice:=min(open,entrylowerband); if myentryprice>0 then begin mycash:=cash(0); if money=0 then begin lots:=1; end else begin lots1:=intpart(mycash/(myentryprice*multiplier*marginratio)); lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier)); lots:=min(lots1,lots2); end end if lots>=1 then buyshort(1,lots,limitr,myentryprice-offsetnum); end if holding>0 then begin myexitprice:=0; if exittime then begin if intraday=0 then begin myexitprice:=open; end else begin if not(costprice<averageprice and averageprice<stopline) then myexitprice:=open; end end if stopline>0 and low<=stopline then myexitprice:=min(open,stopline); if stopline=0 then begin if commission>1 then costprice:=enterprice+2*commission/multiplier; else costprice:=enterprice*(1+commission)/(1-commission); costprice:=ceiling(costprice/mindiff)*mindiff; stopline:=costprice-initialstopnum; end if stopline<costprice and high-breakevenstopnum>=costprice then stopline:=costprice; if stopline>=costprice and high-trailingstopnum>stopline then stopline:=high-trailingstopnum; if exitlowerband>stopline then stopline:=exitlowerband; if myexitprice>0 then begin sell(1,holding,limitr,myexitprice-offsetnum); costprice:=0; stopline:=0; myasset:=asset; end end if holding<0 then begin myexitprice:=0; if exittime then begin if intraday=0 then begin myexitprice:=open; end else begin if not(costprice>averageprice and averageprice>stopline) then myexitprice:=open; end end if stopline>0 and high>=stopline then myexitprice:=max(open,stopline); if stopline=0 then begin if commission>1 then costprice:=enterprice-2*commission/multiplier; else costprice:=enterprice*(1-commission)/(1+commission); costprice:=floor(costprice/mindiff)*mindiff; stopline:=costprice+initialstopnum; end if stopline>costprice and low+breakevenstopnum<=costprice then stopline:=costprice; if stopline<=costprice and low+trailingstopnum<stopline then stopline:=low+trailingstopnum; if exitupperband<stopline then stopline:=exitupperband; if myexitprice>0 then begin sellshort(1,holding,limitr,myexitprice+offsetnum); costprice:=0; stopline:=0; myasset:=asset; end end 保證金:round(close*multiplier*marginratio),linethick0; partline(1,averageprice,colorblue,2); partline(entrytime and holding=0,entryupperband,colorred,2); partline(entrytime and holding=0,entrylowerband,colorgreen,2); if entrytime and holding=0 then begin 上軌:entryupperband,linethick0; 下軌:entrylowerband,linethick0; end if holding>0 then begin 多頭成本:costprice,linethick0; 多頭止損:stopline,linethick0; 多頭盈虧:(stopline-costprice)*multiplier,linethick0; drawicon(stopline<costprice,stopline,11); drawicon(stopline=costprice,stopline,12); drawicon(stopline>costprice,stopline,10); end if holding<0 then begin 空頭成本:costprice,linethick0; 空頭止損:stopline,linethick0; 空頭盈虧:(costprice-stopline)*multiplier,linethick0; drawicon(stopline>costprice,stopline,11); drawicon(stopline=costprice,stopline,12); drawicon(stopline<costprice,stopline,10); end if debug=1 then begin 資產:myasset,noaxis,linethick2,colormagenta; 收益:(myasset-30000)/30000,linethick0; 次數:totaltrade,linethick0; 勝率:percentwin,linethick0; 連虧:maxseqloss,linethick0; 連贏:maxseqwin,linethick0; end 點擊復制上述代碼粘貼到到公式管理器
{別忘了將本網告訴您身邊的朋友,向朋友傳達有用資料,也是一種人情,你朋友會感謝你的。}