zyqh100032595 发表于 2018-8-7 13:46:40

一个好的策略,发出信号不好的 问题

策略
1.布林线带宽<0.05,并且布林线中轨向上,在股价突破布林线上轨时开多仓;
2.布林线带宽<0.05,并且布林线中轨向下,在股价突破布林线下轨时开空仓;
3.布林线带宽<0.5时平仓;


这个策略其实很好的,我经常手工操作,为什么一程序化乱开仓呢,请高手指点!

zyqh100032595 发表于 2018-8-7 13:48:08

//------------------------------------------------------------------------
// 简称: MYBOll
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------


Params
        Numeric Length(20);                       
        Numeric Offset(2);       
        Numeric ATRLength(20);
         Numeric RiskRatio(1);
         numeric width(0.1);
         numeric width2(0.5);
         
       
Vars
        NumericSeries UpLine;                //上轨
        NumericSeries DownLine;                //下轨
        NumericSeries MidLine;        //中间线
        Numeric Band;
        numeric with;
        Numeric MinPoint;                       // 最小变动单位
    NumericSeries AvgTR;                    // ATR
    Numeric N;                              // N 值
    Numeric TotalEquity;                    // 按最新收盘价计算出的总资产
    Numeric TurtleUnits;  
        NumericSeries preEntryPrice(0);
        numeric myEntryPrice;
Begin
        MidLine = AverageFC(Close,Length);
        Band = StandardDev(Close,Length,2);
        UpLine = MidLine + Offset * Band;
        DownLine = MidLine - Offset * Band;
        with=(upline-DownLine)/MidLine;
        PlotNumeric("UpLine",UpLine);
        PlotNumeric("DownLine",DownLine);
        PlotNumeric("MidLine",MidLine);
       
          MinPoint = MinMove*PriceScale;
    AvgTR = XAverage(TrueRange,ATRLength);

          If(!CallAuctionFilter()) Return;

  
If(MarketPosition == 0)
       
  If(with<width && MidLine<MidLine && high>upline)//如果布林线宽小于0.05并且布林轨道中线向上,并且最高价上穿布林上轨;
  
        myEntryPrice = min(high,upline + MinPoint);
        myEntryPrice = IIF(myEntryPrice < Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
               
        Buy(1,myEntryPrice);
               

    If(with<width && MidLine>MidLine && Low<DownLine)
  
        myEntryPrice = max(low,DownLine - MinPoint);
        myEntryPrice = IIF(myEntryPrice > Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
               
        SellShort(1,myEntryPrice);
               
If(marketposition!=0)
  If(with>width2)
     Sell(0,open- MinPoint);
         BuyToCover(0,open+minpoint);
       
       
       
End
页: [1]
查看完整版本: 一个好的策略,发出信号不好的 问题