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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件策略编写求助区 → 求高手将TB 改成金字塔?

   

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


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

主题:求高手将TB 改成金字塔?

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


加好友 发短信
等级:新手上路 帖子:36 积分:220 威望:0 精华:0 注册:2011/10/22 16:23:09
求高手将TB 改成金字塔?  发帖心情 Post By:2012/2/19 11:50:50 [只看该作者]

Params
    Numeric Begintime(9.30);
    Numeric endtime(14.55);
 Numeric lots(1);
 Numeric enFilter(1);                     // 1为使用窄幅过滤,其他为不使用过滤
 Numeric RANGE_LENGTH(7);
 Numeric PERCENT_OF_RANGE(1.10);
 Numeric ratio(0.7);
 Numeric InitialStop(5);                   // 初始止损(千分之N)
 Numeric BreakEvenStop(5);          // 保本止损(千分之N)
 Numeric TrailingStop(5);                // 追踪止损(千分之N)
Vars
    NumericSeries Upperprice;
    NumericSeries lowerprice;
    NumericSeries higherafterentry;
    NumericSeries lowerafterentry;
 BoolSeries cond;
 Numeric avgRange;
 NumericSeries preDayRangezf;
 Numeric yy;
 Numeric MyPrice;
 NumericSeries stopline;
 BoolSeries bLongStoped(false); // 多头止损情况
 BoolSeries bShortStoped(false); // 空头止损情况
Begin
    if(day<>day[1] || CurrentBar==0)
    {
      Upperprice=high;
      lowerprice=low;
   bLongStoped = False;
   bshortStoped = False;
    }else if(time<=Begintime/100 || CurrentBar<30)
   {
      Upperprice=max(upperprice[1],high);
      lowerprice=min(Lowerprice[1],low);
   }Else
   {
      Upperprice=upperprice[1];
      lowerprice=Lowerprice[1];     
   }
 if(BarsSinceEntry==1)
   {
     higherafterentry=AvgEntryPrice;
  lowerafterentry=AvgEntryPrice;
   }else if(BarsSinceEntry>1)
   {
     higherafterentry=max(higherafterentry[1],high[1]);
  lowerafterentry=min(lowerafterentry[1],low[1]);    
   }
    If (enFilter==1)
    {
      avgRange = 0;
      For yy=1 To RANGE_LENGTH
      {
       avgRange = avgRange+(highd(yy)-LowD(yy));
      }
      avgRange = avgRange/RANGE_LENGTH;
      preDayRangezf = HighD(1) - LowD(1);
         cond=(preDayRangezf<=PERCENT_OF_RANGE*avgRange);
    }

Else cond = True;

 

 

求高手将上面TB 改成金字塔? 谢谢~~~~~~~~


    


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


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2012/2/20 11:20:58 [只看该作者]

你的不是完整的模型

 

要的是不是 3级止损啊?论坛上有

 

http://www.weistock.com/bbs/dispbbs.asp?BoardID=11&ID=7320&skin=0

 

 

平均振幅的算法 可采用引用

新建一个指标 名称为 zf    内容如下:avgRange:ma(h-l,20);zf:h-l;

则:avgRange:=stkindi(stklabel,'zf.avgRange',0,6,-1);

      zf:=stkindi(stklabel,'zf.zf',0,6,-1);

 

至于开盘后一定周期内的高低点的写法:

nn:=barslast(date<>ref(date,1) or barpos=1)+1;

yl:=ref(hhv(h,nn),1);

zc:=ref(llv(l,nn),1);

[此贴子已经被作者于2012-2-20 11:36:13编辑过]

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


加好友 发短信
等级:新手上路 帖子:36 积分:220 威望:0 精华:0 注册:2011/10/22 16:23:09
  发帖心情 Post By:2012/2/20 20:02:26 [只看该作者]

主要上面一段不好改,改完的效果和TB出入较大   进退场 代码如下 


if(time<endtime/100 and cond and (upperprice/Lowerprice)<(1+ratio/100) And High<>Low)
  {
if(high>=upperprice[1] and time>begintime/100 and MarketPosition<>1 && bLongStoped==False)
 {
   buy(lots,max(open,Upperprice[1]));
Return;
 }
if(low<=Lowerprice[1] and time>begintime/100 and MarketPosition<>-1 && bshortStoped==False)
 {
   SellShort(lots,Min(open,Lowerprice[1]));
Return;
 }  
  }
//以下为止损部分代码
If(MarketPosition==1 and BarsSinceEntry>=1)
{
// 初始止损
StopLine = EntryPrice * (1-InitialStop/1000);

// 达到保本止损条件,将止损位上移到保本的价位
If (HigherAfterEntry >= EntryPrice * (1+BreakEvenStop/1000))
StopLine = EntryPrice;

// 追踪止损的价位超过保本止损价,止损价随盈利峰值价的上升同步提高
If (StopLine < HigherAfterEntry*(1-TrailingStop/1000))
StopLine = HigherAfterEntry*(1-TrailingStop/1000);
// 止损触发
If(Low <= StopLine)
{
MyPrice = StopLine;
If(Open < MyPrice) MyPrice = Open;
Sell(0,MyPrice);
bLongStoped = True; // 止损后设置标志
//bshortStoped = False;
}
}

If(MarketPosition==-1  and BarsSinceEntry>=1)
{
// 初始止损
StopLine = EntryPrice * (1+InitialStop/1000);

// 达到保本止损条件,将止损位上移到保本的价位
If (lowerAfterEntry <= EntryPrice * (1-BreakEvenStop/1000))
StopLine = EntryPrice;

// 追踪止损的价位超过保本止损价,止损价随盈利峰值价的上升同步提高
If (StopLine > lowerAfterEntry*(1+TrailingStop/1000))
StopLine = lowerAfterEntry*(1+TrailingStop/1000);

Commentary("止损价:"+Text(StopLine));
// 止损触发
If(high >= StopLine)
{
MyPrice = StopLine;
If(Open > MyPrice) MyPrice = Open;
BuyToCover(0,MyPrice);
//bLongStoped = False;
bshortStoped = True; // 止损后设置标志
}
//以下为收盘平仓部分
if(time>=endtime/100 and MarketPosition<>0)
{
 BuyToCover;
 sell;
}
End


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


加好友 发短信
等级:管理员 帖子:7302 积分:32559 威望:1000 精华:45 注册:2003/12/30 16:34:32
  发帖心情 Post By:2012/2/22 15:41:22 [只看该作者]

主要是没人能完全理解你的指标代码原理,建议你学习一下金字塔的一些基本调试技巧 http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=332 问题4,如果遇到了具体的编程问题,再来求教,这样才有比较好的效果

 回到顶部