分享

[策略探讨] 趋势策略

 暴利许可证 2016-08-30
近来欧美股市的波动非常大啊,伊波拉病毒也蠢蠢欲动.....不知道会不会影响到咱们中国,也因此,策略天地在此介绍一个趋势型的策略,让读者们试试,策略优点主要在动态出场,进场随意写的,需要靠用户优化

 

策略适用商品:

 

趋势性较好的商品。下图测试商品IF,3 min周期。

 

原理如下:

 

此策略是根据短期及中长期均线确认行情方向,然后当行情突破近期高低点时进行趋势性开仓。

 

出场停利用常用的三条均线作为出场条件,根据进场后的行情创新高跟新低的次数控制用哪条均线出场,好处是防止刚刚进场后激活短期均线,容易错失大的行情。

 

 

input:x(30),y(120),m(20),n(15);

 

var:ma1(close),ma2(close);

 

ma1=Average(close,x);

 

ma2=Average(close,y);

 

condition1=close>ma1 and ma1>ma2;

 

condition2=close
condition3=high > highest(high,m)[1];
condition4=low < span=""><>
//以上定义变量跟参数,对进场条件进行定义

 

if marketposition=0 and condition1 and condition3 then buy next bar at market;

 

//判断进场条件

 

//////////////////////

 

input:f1(10),f2(20),f3(30),stp(11);
var:av1(0),av2(0),av3(0),position(0),stH(0),Hct(0),stl(0),lct(0);
av1 = average(close, f1);
av2 = average(close, f2);
av3 = average(close, f3);
position = marketposition;
//定义常用的三条移动平均线

 

if position =1 and position[1] =0 then begin

 

stH = high;
Hct =0;
end;
//进场后对第一个bar高点赋值
if position =1 and close > stH then begin
stH = high;
Hct = Hct[1] +1;
end;
//后面对创新高时进行累加计算
if position =1 then begin
if Hct <3 then sell("begin stop") next bar at entryprice - stp stop;
if Hct >=3 and Hct <6 then sell("30stop") next bar at av3 stop;
if Hct >=6 and Hct <9 then sell("20stop") next bar at av2 stop;
if Hct >=9 then sell ("10stop") next bar at av1 stop;
end;
//当有持仓时,累加值作为激活某条均线的出场条件,有长期均线激活开始,这样可以防止进场后快速被洗出来。

 

////////////////////////

 

if marketposition=0 and condition2 and condition4 then sellshort next bar at market;
if position =-1 and position[1] =0 then begin
stl = low;
lct =0;
end;
if position =-1 and close < stl then begin
stl = low;
lct = lct[1] +1;
end;
if position =-1 then begin
if lct <3 then buytocover("begin stop1") next bar at entryprice + stp stop;
if lct >=3 and lct <6 then buytocover("30stop1") next bar at av3 stop;
if lct >=6 and lct <9 then buytocover("20stop1") next bar at av2 stop;
if lct >=9 then buytocover ("10stop1") next bar at av1 stop;
end;
//原理跟上面的多单进场出场条件判断一致,方向相反操作

展示图如下:

 

 

 

 

 

标签: 策略投资 举报

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多