设为首页收藏本站

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

分享一个股指程序IF_5min [复制链接]

Rank: 5Rank: 5

精华
0
UID
116737
积分
781
帖子
210
主题
32
阅读权限
60
注册时间
2013-3-14
最后登录
2019-8-16
跳转到指定楼层
1#
发表于 2014-9-17 16:26:41 |只看该作者 |倒序浏览
本帖最后由 yebenli 于 2014-9-17 16:42 编辑

一个做多模块,一个做空模块,同时运行就可以减少回撤。
  1.   
  2. Params
  3.         Numeric Lots(1);

  4. Vars
  5.         NumericSeries length(20);
  6.         NumericSeries UpBand;
  7.         NumericSeries DnBand;
  8.         NumericSeries MidBand;

  9. Begin

  10.         IF(MarketPosition==0)
  11.         {
  12.                 Length=20;
  13.         }
  14.         IF(MarketPosition<>0)
  15.         {
  16.                 Length=Min(120,length+1);
  17.         }
  18.        
  19.         UpBand=Highest(High[1],Length);
  20.         DnBand=Lowest(Low[1],Length);
  21.         MidBand=(UpBand+Dnband)/2;

  22.         PlotNumeric("UpBand",UpBand);
  23.         PlotNumeric("DnBand",DnBand);
  24.         PlotNumeric("MidBand",MidBand);
  25.        
  26.         if( MarketPosition==0 )
  27.         {
  28.                 If ( C[1]>UpBand[1] && C[2]>UpBand[2] && H>=H[1])
  29.                 {
  30.                         Buy(Lots,Max(O,H[1]) );
  31.                 }
  32.           
  33.         }

  34.         //出场
  35.         if( MarketPosition>0 && L<=midband && BarsSinceEntry>=1 )
  36.         {
  37.                 Sell(Lots,Min(O,midband));
  38.         }
  39.         Commentary("length="+Text(Length));

  40. End
复制代码
  1. Params
  2.         Numeric Lots(1);
  3. Vars
  4.         NumericSeries length(20);
  5.         NumericSeries UpBand;
  6.         NumericSeries DnBand;
  7.         NumericSeries MidBand;

  8. Begin
  9.        


  10.         IF(MarketPosition==0)
  11.         {
  12.                 Length=20;
  13.         }
  14.         IF(MarketPosition<>0)
  15.         {
  16.                 Length=Min(120,length+1);
  17.         }
  18.         UpBand=Highest(High[1],Length);
  19.         DnBand=Lowest(Low[1],Length);
  20.         MidBand=(UpBand+Dnband)/2;
  21.         PlotNumeric("UpBand",UpBand);
  22.         PlotNumeric("DnBand",DnBand);
  23.         PlotNumeric("MidBand",MidBand);
  24.         if( MarketPosition==0  )
  25.         {

  26.                 If ( C[1]<DnBand[1] && C[2]<DnBand[2]  && L<=L[1])
  27.                 {
  28.                         SellShort(Lots,Min(O,L[1]) );
  29.                 }
  30.         }

  31.         if( MarketPosition<0 && H>=midband && BarsSinceEntry>=1 )
  32.         {
  33.                 BuyToCover(Lots,Max(O,midband));
  34.         }
  35.         Commentary("length="+Text(Length));
  36.          
  37. End
复制代码
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

Rank: 4

精华
0
UID
240
积分
433
帖子
23
主题
4
阅读权限
50
注册时间
2007-9-1
最后登录
2019-4-5
2#
发表于 2014-9-21 01:03:04 |只看该作者
这个程序比较简单,但过滤效果还不错,赞一个!

使用道具 举报

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

bottom

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

GMT+8, 2024-5-7 20:11

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部