设为首页收藏本站

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

【系统案例】一种有名的趋势交易系统 [复制链接]

Rank: 4

精华
0
UID
2423
积分
402
帖子
17
主题
6
阅读权限
50
注册时间
2008-9-22
最后登录
2019-3-30
1#
发表于 2009-2-1 14:53:32 |显示全部楼层
试着写了一下,没有用穿越模式,可能效果有些不同
有不对之处请高手指出!
Params
Numeric avgLength(40);
Numeric atrLength(40);
Numeric LongLots(1);                // 开多仓的手数
Numeric ShortLots(1);                // 开空仓的手数


Vars
Numeric MinPoint;                        // 最小变动单位
NumericSeries upBand(0);
NumericSeries dnBand(0);
NumericSeries liquidPoint(0);
NumericSeries movAvgVal(0);
Numeric MyPrice;                                // 临时价格



Begin
  MinPoint = MinMove*PriceScale;
  movAvgVal = Average((High + Low + Close)/3,avgLength);

  upBand = movAvgVal+AvgTrueRange(atrLength);

  dnBand = movAvgVal-AvgTrueRange(atrLength);
  
  liquidPoint = Average(((High + Low + Close)/3),40);

  If(MarketPosition!=1 && movAvgVal>movAvgVal[1]&&High>=upBand+minpoint)
     {  MyPrice = upBand+minpoint;
                If(Open > MyPrice) MyPrice = Open;

                Buy(LongLots,MyPrice);
         }
  else If(MarketPosition!=-1 && movAvgVal<movAvgVal[1]&&Low<=dnBand-minpoint)
     {  MyPrice = dnBand-minpoint;
                If(Open < MyPrice) MyPrice = Open;

                SellShort(ShortLots,MyPrice);
         }
       
   //持仓处理
   If(MarketPosition == 1 )
    {If(Low <= liquidPoint) // 跟踪止损退出
                {
                        MyPrice =liquidPoint;
                        If(Open < MyPrice) MyPrice = Open;
                        Sell(LongLots,MyPrice);
                        Return;
                }   
     } Else If(MarketPosition == -1)
         {
                If( High >= liquidPoint) // 跟踪止损退出
                {
                        MyPrice = liquidPoint;
                        If(Open > MyPrice) MyPrice = Open;
                        BuyToCover(ShortLots,MyPrice);
                        Return;
                }
        }
       
End

使用道具 举报

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

bottom

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

GMT+8, 2024-5-4 06:19

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部