三兵连营策略

来源:mc官网

这次再来介绍一个趋势策略,用大家熟悉的布林通道所组成,提供学习参考

策略原理:
模型通过红绿三兵进行形态识别、利用布林通道上下轨确定价格的相对位置、辅以布林中轨均线过滤及设定价格高低点突破作为开仓信号。出场采用之前的移动停利出场方式,可以自己拓展出场模式。

此策略未做任何优化,参数都是默认常用值,自己可以调整,适合商品趋势行情。

测试螺纹钢期货,数据从2016/1/1~2018/1/3,周期1分K,手续费每笔6元,绩效如下,看起来还不错。

代码:

inputs:

BollingerPrice( Close ),

TestPriceUBand( Close ),

TestPriceLBand( Close ),

Length( 20 ),

NumDevsUp( 2 ),

NumDevsDn( -2 ),

Displace( 0 ) ,

mm(10);

variables:

var0( 0 ),

var1( 0 ),

var2( 0 ),

var3( 0 ) ;

var0 = AverageFC( BollingerPrice, Length ) ;

var1 = StandardDev( BollingerPrice, Length, 1 ) ;

var3 = var0 + NumDevsUp * var1 ;

var2 = var0 + NumDevsDn * var1 ;

////////////////////////////////////////////////???

condition1=CountIf(close>open,3)>=3;

condition2=CountIf(close>close[1],3)>=3;

condition3=CountIf(open>open[1],3)>=3;

condition4=open>open[1] and open[1]>open[2]and close>close[1] and close[1]>close[2];

condition10=CountIf(var3>var3[1],5)>=5;

if condition1 and condition2 and condition3 and condition4

and marketposition=0 and close>=Average(var0,mm) and condition10 then buy(“BK”) next bar at Highest(high,3) stop;

/////////////////////////////////////////////???boll???

condition5=CountIf(close<open,3)>=3;

condition6=CountIf(close<close[1],3)>=3;

condition7=CountIf(open<open[1],3)>=3;

condition8=close<close[1] and close[1]<close[2] and open<open[1] and open[1]<open[2];

condition11=CountIf(var3<var3[1],5)>=5;

if condition5 and condition6 and condition7 and condition8

and marketposition=0 and close<Average(var0,mm) and condition11 then sellshort(“SK”) next bar at lowest(low,3) stop;

///////////////////////////////////////////////???boll???

input:stoppoint(10);

var:longstop(0),barHH(0);

if barssinceentry=0 then begin

longstop=minlist(low,low[1])-stoppoint;

barHH=high;

end;

if high>barHH then barHH=high;

if barssinceentry>0 then begin

if c>barHH[1] then longstop=minlist(low,low[1])-stoppoint;

end;

if marketposition=1 then sell(“EL”) next bar at longstop stop ;

input:stoppoint1(10);

var:longstop1(0),barll(0);

if barssinceentry=0 then begin

longstop1=maxlist(high,high[1])+stoppoint;

barll=low;

end;

if low<barll then barll=low;

if barssinceentry>0 then begin

if c<barll[1] then longstop1=maxlist(high,high[1])+stoppoint;

end;

if marketposition=-1 then buytocover(“EX”) next bar at longstop1 stop ;

/////////////////////////////////////////////////???

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值