欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请高手将一个TB交易系统修改为金字塔交易系统

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5912人关注过本帖树形打印复制链接

主题:请高手将一个TB交易系统修改为金字塔交易系统

帅哥哟,离线,有人找我吗?
CITSCWB
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:96 积分:413 威望:0 精华:0 注册:2010/3/12 10:56:49
请高手将一个TB交易系统修改为金字塔交易系统  发帖心情 Post By:2011/6/11 14:34:55    Post IP:182.149.19.190[只看该作者]

Params
 Numeric PercentOfRange(0.4);
 Numeric MinRange(0.2);
 Numeric StopLossSet(0.2);
 Numeric LastTradeMins(14.50);
 Numeric ExitOnCloseMins(14.55);
 Numeric Begintradetime(9.30);
 Numeric Lots(1);
 Numeric TrailingStart(0.1);
 Numeric TrailingStop(0.5);
 Numeric FailureLimit(2);
       Numeric Rangefilter1(0);
       Numeric Rangefilter2(1.5);
    Numeric slip(1);

Vars
    NumericSeries DayOpen;
    Numeric preDayHigh;
    Numeric preDayLow;   
    NumericSeries preDayRange;
 Numeric UpperBand;
 Numeric LowerBand;
 Numeric MyPrice;
 Numeric StopLine;
 NumericSeries HigherAfterEntry;
    NumericSeries LowerAfterEntry;
 BoolSeries  bLongStoped;
    BoolSeries  bShortStoped;
 Numeric MinPoint;
 Bool bInBoardRange;
 NumericSeries FailureCnts;
       NumericSeries range;


Begin
   

    MinPoint = MinMove*PriceScale;
    preDayHigh = HighD(1);
    preDayLow = LowD(1);
   
    range=((preDayHigh-preDayLow)/preDayLow)*100;
    If(range>Rangefilter2)
    {
    Return;
    }
 If(range<Rangefilter1)
 {
 Return;
 }
    If(Date!=Date[1])
    {
        DayOpen = Open;
        preDayRange = preDayHigh - preDayLow;
        If(preDayRange < Open*MinRange*0.01)
  preDayRange = Open*MinRange*0.01;
  bLongStoped = False;
     bShortStoped = False;
     HigherAfterEntry = High;
     LowerAfterEntry = Low;
  FailureCnts = 0;
    }Else
    {
        DayOpen = DayOpen[1];
        preDayRange = preDayRange[1];
     bLongStoped = bLongStoped[1];
     bShortStoped = bShortStoped[1];
  HigherAfterEntry = max(HigherAfterEntry[1],High[1]);
        LowerAfterEntry = min(LowerAfterEntry[1],Low[1]);
        If(BarsSinceEntry == 1)
        {
         //If (MarketPosition==1)
   HigherAfterEntry = AvgEntryPrice;
         //If (MarketPosition==-1)
   LowerAfterEntry = AvgEntryPrice;
        }
  FailureCnts = FailureCnts[1];
    }
    Commentary("FailureCnts="+Text(FailureCnts));
 Commentary("bLTrue","False"));
    Commentary("bShortStoped="+IIFString(bShortStoped,"True","False"));
 

 Commentary("HigherAfterEntry="+Text(HigherAfterEntry));
    Commentary("LowerAfterEntry="+Text(LowerAfterEntry));
 
 UpperBand = DayOpen + preDayRange*PercentOfRange;
 LowerBand = DayOpen - preDayRange*PercentOfRange;
 
 bInBoardRange = (Open < Q_LowerLimit + DayOpen*StopLossSet*0.02) Or ( Open > Q_UpperLimit - DayOpen*StopLossSet*0.02);
 
 If(Open == Q_UpperLimit) Sell(1,Open);
 If(Open == Q_LowerLimit) BuyToCover(Lots,Open);
 
 If(MarketPosition!=1 && High>=UpperBand && Time < LastTradeMins/100 && bLongStoped==False && FailureCnts < FailureLimit&&Time>(Begintradetime/100))
 {
  MyPrice = UpperBand;
  If(Open > MyPrice) MyPrice = Open+slip;
  Buy(Lots,MyPrice);
  bLongStoped = True;
  Return;
 }
 If(MarketPosition!=-1 && Low<=LowerBand && Time < LastTradeMins/100 && bShortStoped==False && FailureCnts < FailureLimit&&Time>(Begintradetime/100))
 {
  MyPrice = LowerBand;
  If(Open < MyPrice) MyPrice = Open-slip;
  SellShort(Lots,MyPrice);
  bShortStoped = True;
  Return;
 }
    If(MarketPosition==1)
    {
     If(HigherAfterEntry>=AvgEntryPrice+DayOpen*TrailingStart*0.01)
     {
      StopLine = HigherAfterEntry - DayOpen*TrailingStop*0.01;
     }Else // 止损
     {
      StopLine = AvgEntryPrice-DayOpen*StopLossSet*0.01;
     }
     If(Low <= StopLine)
     {
   If(PositionProfit < 0 ) FailureCnts = FailureCnts + 1;
      MyPrice = StopLine;
      If(Open < MyPrice) MyPrice = Open-slip;
      Sell(Lots,MyPrice);
   bLongStoped = True;
            Return;
     }
    }
 Else If(MarketPosition==-1)
    {
     If(LowerAfterEntry<=AvgEntryPrice-DayOpen*TrailingStart*0.01)
     {
      StopLine = LowerAfterEntry + DayOpen*TrailingStop*0.01;
     }Else // 止损
     {
         StopLine = AvgEntryPrice+DayOpen*StopLossSet*0.01;
  }
     If(High >= StopLine)
     {
   If(PositionProfit < 0 ) FailureCnts = FailureCnts + 1;
      MyPrice = StopLine;
      If(Open > MyPrice) MyPrice = Open+slip;
      BuyToCover(Lots,MyPrice);
   bShortStoped= True;
            Return;
     }
    }
 
 //突破前期高低点再次入场
 If(bLongStoped && MarketPosition==0 && High > HigherAfterEntry && Time < LastTradeMins/100  && FailureCnts < FailureLimit)
 {
  MyPrice = HigherAfterEntry + MinPoint;
  If(Open > MyPrice) MyPrice = Open+slip;
  Buy(Lots,MyPrice);
  bLongStoped = False;
  Return;
 }
 If(bShortStoped && MarketPosition==0 && Low < LowerAfterEntry && Time < LastTradeMins/100  && FailureCnts < FailureLimit)
 {
  MyPrice = LowerAfterEntry - MinPoint;
  If(Open < MyPrice) MyPrice = Open-slip;
  SellShort(Lots,MyPrice);
  bShortStoped= False;
  Return;
 }

 // 收盘平仓
 If(Time >=ExitOnCloseMins/100)
 {
  Sell(Lots,Open+slip);
  BuyToCover(Lots,Open-slip);
 }
 SetExitOnClose;
End

[此贴子已经被作者于2011-6-11 14:37:10编辑过]


查看使用道具详细信息
悬赏金币帖,要悬赏 1 个金币
 回到顶部
帅哥哟,离线,有人找我吗?
26327756l
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:676 积分:2548 威望:0 精华:3 注册:2011/4/13 16:18:50
  发帖心情 Post By:2011/6/13 10:16:49    Post IP:58.246.57.26[只看该作者]

看不懂,不如你把策略用语言文字描写出来,看看能不能写.


获得0个金币
 回到顶部