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


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

   

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


  共有5188人关注过本帖平板打印复制链接

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

帅哥哟,离线,有人找我吗?
shshtiger
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部