开拓者期货期权程序化系统交易论坛

标题: 分享一个股指程序IF_5min [打印本页]

作者: yebenli    时间: 2014-9-17 16:26:41     标题: 分享一个股指程序IF_5min

本帖最后由 yebenli 于 2014-9-17 16:42 编辑

一个做多模块,一个做空模块,同时运行就可以减少回撤。
[attach]30296[/attach]
  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
复制代码

作者: zhc1234    时间: 2014-9-21 01:03:04

这个程序比较简单,但过滤效果还不错,赞一个!




欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2