- //策略:Dual Thrust
- //类型:日内
- //中间变量*
- input:n(1,1,100,1),K1(0.7,0.1,1,0.1),k2(0.7,0.1,1,0.1),nmin(10,1,100,1),ss(1,1,100,1);.
- 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
- t2:=time>=closetime(0)-nmin*100;
- 手数:=ss;
- //交易条件
- 开多条件:=c>上轨 and holding=0;
- 开空条件:=c<下轨 and holding=0;
- //交易系统
- 开多:buy(开多条件 and t1 and cyc>1,手数,market);
- 开空:buyshort(开空条件 and t1 and cyc>1,手数,market);
- 收盘平多:sell(t2,手数,market);
- 收盘平空:sellshort(t2,手数,market);
复制代码
|