设为首页收藏本站

 找回密码
 注册
查看: 3156|回复: 2
打印 上一主题 下一主题

形态交易法 [复制链接]

Rank: 2

精华
0
UID
109379
积分
112
帖子
30
主题
10
阅读权限
30
注册时间
2012-4-5
最后登录
2019-10-10
跳转到指定楼层
1#
发表于 2013-8-7 16:22:31 |只看该作者 |倒序浏览
     现在均线系统已经为大多数人所熟知,所谓主力资金,运用的就更是得心应手,正着用,反着用,无所不用其极。手工交易使用普通均线系统,配合自己经验,心态好的话,或能取得不错成绩。然而使用量化交易,使用可编程的平台,简单使用均线开平仓,就太浪费了。

        形态交易法,作为一个完全不同于均价系统的交易方法,在国外有长足发展,国内的缠论,说的比较好,推荐《缠中说禅》
      
最近看博客,看到这么一个做单思路。收盘价创新高的Bar,如果后面bar的收盘价跌破,之前收盘价创新高的Bar的最低价,表明涨势逆转,平多开空,否则一直拿着。
反之,收盘价创新低,如果后面BAR收盘价向上突破,收盘价创新低bar的最高价,表明空头逆转,平空开多。
      中间最核心的问题设计,Hightest(c[1],n1)、lowest(c[1],n2),   其中n1 n2  不能简单采用固定值统计,否则会乱。
      n1,n2统计口径采取,循环递归,初始值20.
      程序代码如下:
Params
        Numeric          N(20);

Vars

        NumericSeries ZCPoint(0);
        NumericSeries YLPoint(0);
        NumericSeries PreHCount(0);   //前高点距离当前Bar度量
        NumericSeries PreLCount(0);          //前低点距离当前Bar度量
        NumericSeries PreExtremCount(0);
        NumericSeries SecYLPoint(0);
        NumericSeries SecZCPoint(0);
       
        NumericSeries ExtremCount(0);
        NumericSeries ZCPoint2(0);
        NumericSeries YLPoint2(0);
        NumericSeries PreHCount2(0);   //前高点距离当前Bar度量
        NumericSeries PreLCount2(0);          //前低点距离当前Bar度量

        NumericSeries HBar_Count(0);
        NumericSeries LBar_Count(0);
        NumericSeries Hbar_index(0);
        NumericSeries LBar_index(0);
        NumericSeries                  N1(0);
        Numeric                  N2(0);
        Numeric OemEnd(20130901);
       
       
       
       

Begin
        //If(CurrentBar<=21)  Return;
        if(date>=OemEnd){While(true) Commentary("试用账号已过期请联系开发人员");}
        /***************************/
        If(LBar_Count+1>1 && CurrentBar>=20)
                {
                        N1=Min(LBar_Count+1,N);
                }Else
                {
                        N1=N;
                }       
        HBar_Count=HighestBar(c[1],N1)+1;                //N1 为二次返回变量 LBAR_COUNT 与 标准N的运算
        //Commentary("测试"+Text(HighestBar(C[1],20)+1));
        Commentary("N1="+Text(n1)+" HBar_Count="+Text(HBar_Count));
        If(c[1]==Highest(C[1],N1))
                {
                        Hbar_index=CurrentBar-HBar_Count;
                        Commentary("创新高标志位");
                        Commentary("CurrentBar"+Text(CurrentBar));
                       
                }
        /************************/
        If(HBar_Count+1>1 && CurrentBar>=20)
                {
                        N2=Min(HBar_Count+1,N);
                }Else
                {
                        N2=N;
                }
        LBar_Count=LowestBar(C[1],N2)+1;
        Commentary("N2="+Text(N2)+" LBAR_COUNT="+Text(LBAR_COUNT));
        If(C[1]==Lowest(C[1],N2))                           //N2为 一次返回变量HBar_Count 与标准N的运算
                {
                        LBar_index=CurrentBar-LBar_Count;       
                        Commentary("创新低标志位");
                }
       
        //Commentary("N1="+TEXT(N1)+"  N2="+Text(n2));
        ZCPoint=L[CurrentBar-Hbar_index];
        Commentary("支撑点"+Text(ZCPoint)+"--"+Text(CurrentBar-Hbar_index));
       
        YLPoint=h[CurrentBar-LBar_index];
        Commentary("压力点"+Text(YLPoint)+"--"+Text(currentBar-LBar_index));
       
       
       
        Commentary("持仓标志="+Text(MarketPosition));
        /*if(MarketPosition<>1)
                {
                        if(c[2]>YLPoint[2] && c[1]>YLPoint[1] && C[1]>O[1]+0.4)
                        Buy(1,O);
               
                }
        if(MarketPosition<>-1)
                {
                        if(c[2]<ZCPoint[2]&&c[1]<ZCPoint[1]  && C[1]<O[1]-0.4)
                        SellShort(1,O);
                }
        */
        if(MarketPosition<>1)
                {
                        if(c[1]>YLPoint )
                        Buy(1,O);
               
                }
        if(MarketPosition<>-1)
                {
                        if(c[1]<ZCPoint )
                        SellShort(1,O);
                }

End

截图如下:


抛砖引玉,大家一起学习。QQ:547080534




附件: 你需要登录才可以下载或查看附件。没有帐号?注册
以信为本 点石成金

Rank: 5Rank: 5

精华
0
UID
73474
积分
1249
帖子
695
主题
30
阅读权限
60
注册时间
2011-10-22
最后登录
2015-11-6
2#
发表于 2013-8-7 18:33:50 |只看该作者
这个模型,用在什么周期、什么品种绩效,比较好啊?

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
73474
积分
1249
帖子
695
主题
30
阅读权限
60
注册时间
2011-10-22
最后登录
2015-11-6
3#
发表于 2013-8-7 18:34:13 |只看该作者
这个模型,用在什么周期、什么品种绩效比较好啊?

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-19 16:22

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部