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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件策略编写求助区 → [求助]请求将TB四周法则改写为金字塔图表逐K线语言程序

   

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


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

主题:[求助]请求将TB四周法则改写为金字塔图表逐K线语言程序

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


加好友 发短信
等级:论坛游民 帖子:431 积分:2515 威望:0 精华:0 注册:2011/9/30 14:12:32
[求助]请求将TB四周法则改写为金字塔图表逐K线语言程序  发帖心情 Post By:2011/10/22 2:34:25 [显示全部帖子]

以下为TB四周法则原代码第一部分:

Params

         Numeric B_Length1(22);// 长周期突破

         Numeric B_Length2(4);

         Numeric B_ATRLength(32);// 多头ATR周期

         Numeric B_TrailStopNumATR(1.80);//多头 追踪止损,回撤Average ATR的倍数

         Numeric S_Length1(8);        

         Numeric S_Length2(30);

         Numeric S_ATRLength(12);// 空头ATR周期

         Numeric S_TrailStopNumATR(4);// 空头追踪止损

         Numeric lots(1);// 头寸大小

 

Vars

         Numeric HiBand1;

         Numeric HiBand2;

         Numeric LoBand1;

         Numeric LoBand2;

         NumericSeries ATRValue;

         Numeric MyPrice;

         Numeric StopLine;

         NumericSeries HigherAfterEntry;

         NumericSeries LowerAfterEntry;

 

//以下多头

Begin

         // 记录开仓后盈利峰值价

         If(BarsSinceEntry == 1)

         {

                   HigherAfterEntry = AvgEntryPrice;

         }Else If(BarsSinceEntry > 1)

         {

                   HigherAfterEntry = Max(HigherAfterEntry[1],High[1]);

         }Else

         {

                   HigherAfterEntry = HigherAfterEntry[1];

         }

         Commentary("HigherAfterEntry="+Text(HigherAfterEntry));

 

         ATRValue = AvgTrueRange(B_ATRLength);

         Commentary("ATRValue="+text(ATRValue));

 

         HiBand1 = highest(high[1],B_Length1);

         LoBand1 = lowest(low[1],B_Length1);

    HiBand2 = highest(high[1],B_Length2);

         LoBand2 = lowest(low[1],B_Length2);

         PlotNumeric("HiBand1",HiBand1);

         PlotNumeric("LoBand1",LoBand1);

         plotnumeric("HiBand2",HiBand2);

         plotnumeric("LoBand2",LoBand2);

 

         // 过滤集合竞价

         If((BarType==1 or BarType==2) && BarStatus == 2 && date!=date[1] && high==low) return;

         If(BarType==0 && BarStatus == 2 && CurrentTime<=0.09 && high==low) return;

 

         // 进场部分

         if(MarketPosition==0 && high>=HiBand1)

         {

                   MyPrice = HiBand1;

                   if (Open>MyPrice) MyPrice = Open;

                   buy(lots,MyPrice);

         }

 

请求将TB四周法则(本楼第一部分与下一楼第二部分一起为完整策略)改写为金字塔图表逐K线语言程序,谢谢.


 回到顶部
帅哥哟,离线,有人找我吗?
xxb398
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:431 积分:2515 威望:0 精华:0 注册:2011/9/30 14:12:32
  发帖心情 Post By:2011/10/22 2:39:39 [显示全部帖子]

以下为TB四周法则原代码第二部分:

         // 止损部分

         if(barssinceentry>=1)

         {

                   If(MarketPosition==1)

                   {

                            StopLine = LoBand2;

                            if (StopLine < HigherAfterEntry - ATRValue[1] * B_TrailStopNumATR)

                                     StopLine = HigherAfterEntry - ATRValue[1] * B_TrailStopNumATR;

 

                            If(Low <= StopLine)

                            {

                                     MyPrice = StopLine;

                                     If(Open < MyPrice) MyPrice = Open;

                                     Sell(Lots,MyPrice);

                            }

                   }

         } 

 

//以下空头

         // 记录开仓后盈利峰值价

         If(BarsSinceEntry == 1)

         {

                   LowerAfterEntry = AvgEntryPrice;

         }Else If(BarsSinceEntry > 1)

         {

                   LowerAfterEntry = Min(LowerAfterEntry[1],Low[1]);

         }Else

         {

                   LowerAfterEntry = LowerAfterEntry[1];

         }

         Commentary("LowerAfterEntry="+Text(LowerAfterEntry));

 

         ATRValue = AvgTrueRange(S_ATRLength);

         Commentary("ATRValue="+text(ATRValue));

 

         HiBand1 = highest(high[1],S_Length1);

         LoBand1 = lowest(low[1],S_Length1);

    HiBand2 = highest(high[1],S_Length2);

         LoBand2 = lowest(low[1],S_Length2);

         PlotNumeric("HiBand1",HiBand1);

         PlotNumeric("LoBand1",LoBand1);

         plotnumeric("HiBand2",HiBand2);

         plotnumeric("LoBand2",LoBand2);

 

         // 过滤集合竞价

         If((BarType==1 or BarType==2) && BarStatus == 2 && date!=date[1] && high==low) return;

         If(BarType==0 && BarStatus == 2 && CurrentTime<=0.09 && high==low) return;

        

         // 进场部分

         if(MarketPosition==0 && Low<=LoBand1)

         {

                   MyPrice = LoBand1;

                   if (Open<MyPrice) MyPrice = Open;

                   SellShort(lots,MyPrice);

         }

 

请求将TB四周法则(第二楼装不下、还有第三楼,3部分一起为完整策略)改写为金字塔图表逐K线语言程序,谢谢。


 回到顶部
帅哥哟,离线,有人找我吗?
xxb398
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:431 积分:2515 威望:0 精华:0 注册:2011/9/30 14:12:32
  发帖心情 Post By:2011/10/22 2:41:26 [显示全部帖子]

以下为TB四周法则原代码第三部分:

         // 止损部分

         if(barssinceentry>=1)

         {

                   If(MarketPosition==-1)

                   {

                            StopLine = HiBand2;

                            if (StopLine > LowerAfterEntry + ATRValue[1] * S_TrailStopNumATR)

                                     StopLine = LowerAfterEntry + ATRValue[1] * S_TrailStopNumATR;

 

                            If(high >= StopLine)

                            {

                                     MyPrice = StopLine;

                                     If(Open > MyPrice) MyPrice = Open;

                                     BuyToCover(Lots,MyPrice);

                            }

                   }

         }

End

 

请求将TB四周法则(第一、二、三楼,3部分一起为完整策略)改写为金字塔图表逐K线语言程序,谢谢。


 回到顶部
帅哥哟,离线,有人找我吗?
xxb398
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:431 积分:2515 威望:0 精华:0 注册:2011/9/30 14:12:32
  发帖心情 Post By:2011/10/31 14:26:01 [显示全部帖子]

非常感谢阿火,以后少不了再麻烦转换TB的一些策略。回复晚了请见谅,因最近忙于TB策略的真实盘。

 回到顶部
帅哥哟,离线,有人找我吗?
xxb398
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:431 积分:2515 威望:0 精华:0 注册:2011/9/30 14:12:32
  发帖心情 Post By:2011/10/31 16:36:30 [显示全部帖子]

逻辑写得好、效率高,一调就通!

1、就是在编译时有以下提示:系统发现...使用<DYNAINFO>返回常数变量的函数,如果使用不当则会导致信号消失等漏单情况...

看到这是过滤集合竞价用到的函数,请问没什么关系吧?

2、在每个自动交易策略中,一定要有过滤集合竞价吗?

谢谢


 回到顶部