-- 作者:bizstar
-- 发布时间:2013/3/26 10:21:20
-- 呼叫阿火版主
阿火版主,你的这个模型,我试过怎么开仓好像有漏单现象呢。请再开下。谢谢
七、把各种模型组合成一个模型的方法,适用于所有模型,即便是“即时下单模型”。
对于信号在同一个点位的模型(比如都是开盘价),可以实盘图表化交易
说明:因为图表交易同一根K线出现2个开多信号的话,只会开一次,另外一个无法执行,但是可以做历时回测
组合起来的模型,加入后台下单语句,就可以用于后台下单,当然,后台下单用“后台下单模板”会更好用。
方法原理:计算每个时点要下单的手数和方向,再根据holding判断出要平仓和开仓的数量,然后再下单。
看起来很多,其实很简单,最基本得模块就是蓝色部分
input:cang1(1,0,10,1),cang2(1,0,10,1); variable:cc1=0,cc2=0;
/////////////////////////////////模型1——10周期反手 hi:=ref(hhv(h,10),1); lo:=ref(llv(l,10),1); if cc1>0 and l<lo then begin pc:=min(max(holding,0),cang1); kc:=cang1-pc; if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6); if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6); cc1:=0; end if cc1<0 and h>hi then begin pc:=min(abs(min(holding,0)),cang1); kc:=cang1-pc; if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6); if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6); cc1:=0; end if cc1=0 and h>hi then begin pc:=min(abs(min(holding,0)),cang1); kc:=cang1-pc; if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6); if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6); cc1:=1; end if cc1=0 and l<lo then begin pc:=min(max(holding,0),cang1); kc:=cang1-pc; if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6); if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6); cc1:=-1; end
/////////////////////////////////以上是模型1
/////////////////////////////////模型2——20周期反手 hi:=ref(hhv(h,20),1); lo:=ref(llv(l,20),1); if cc2>0 and l<lo then begin pc:=min(max(holding,0),cang2); kc:=cang2-pc; if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6); if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6); cc2:=0; end if cc2<0 and h>hi then begin pc:=min(abs(min(holding,0)),cang2); kc:=cang2-pc; if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6); if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6); cc2:=0; end if cc2=0 and h>hi then begin pc:=min(abs(min(holding,0)),cang2); kc:=cang2-pc; if pc>0 then sellshort(1,pc,limitr,max(o,hi+0.2)+0.6); if kc>0 then buy(1,kc,limitr,max(o,hi+0.2)+0.6); cc2:=1; end if cc2=0 and l<lo then begin pc:=min(max(holding,0),cang2); kc:=cang2-pc; if pc>0 then sell(1,pc,limitr,min(o,lo-0.2)-0.6); if kc>0 then buyshort(1,kc,limitr,min(o,lo-0.2)-0.6); cc2:=-1; end
/////////////////////////////////以上是模型2
//有更多的模型,往后面添加即可
|