您现在的位置:程序化交易>> 期货公式>> (MC)multicharts>> MC知识>>正文内容

期货期权交流趋势策略-三均线利剑 [MC]

  • 咨询内容: 近来欧美股市的波动非常大啊,伊波拉病毒也蠢蠢欲动.....不知道会不会影响到咱们中国,也因此,策略天地在此介绍一个趋势型的策略,让读者们试试,策略优点主要在动态出场,进场随意写的,需要靠用户优化
    策略适用商品:趋势性较好的商品。下图测试商品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<ma1 and ma1<ma2;condition3=high > highest(high,m)[1];condition4=low <lowest(low,n)[1];//以上定义变量跟参数,对进场条件进行定义
    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 beginstH = high;Hct =0;end;//进场后对第一个bar高点赋值
    if position =1 and close > stH then beginstH = high;Hct = Hct[1] +1;end;//后面对创新高时进行累加计算
    if position =1 then beginif 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 beginstl = low;lct =0;end;if position =-1 and close < stl then beginstl = low;lct = lct[1] +1;end;if position =-1 then beginif 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;//原理跟上面的多单进场出场条件判断一致,方向相反操作
    此策略参数未做优化处理,都是常用的数值,可以按照此思路作为之后策略的出场判断。
    展示图如下:





    three_sword.pla

    2014-10-21 10:00 上传

    点击文件名下载附件

    4.94 KB, 下载次数: 12

    售价: 10 金钱  [记录]

    源代码下载

     

  • MC技术部: 学习了,不错的思路

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 511411198  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容