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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]求高人将下面的程序改成适合在金字塔中运行的语句

   

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


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

主题:[求助]求高人将下面的程序改成适合在金字塔中运行的语句

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


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2011/2/22 12:06:45    Post IP:123.118.94.16[显示全部帖子]

带跟踪止损的区间突破系统


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


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2011/2/22 13:23:53    Post IP:123.118.94.16[显示全部帖子]

runmode:0;

input:percentOfRange(0.3,0.1,1,0.1);
input:minRange(0.2,0.1,1,0.1);
input:stopLossSet(0.5,0.1,1,0.1);
input:trailingStart(0.8,0.1,1,0.1);
input:trailingStop(0.5,0.1,1,0.1);

variable:longStopped=false;
variable:shortStopped=false;
variable:stopLine=0;

preDayHigh:=callstock(stklabel,vthigh,6,-1);
preDayLow:=callstock(stklabel,vtlow,6,-1);

dayOpen:=valuewhen(date<>ref(date,1),open);
preDayRange:=preDayHigh-preDayLow;

if preDayRange<dayOpen*minRange*0.01 then
 preDayRange:=dayOpen*minRange*0.01;

upperBand:=trimprice(dayOpen+preDayRange*percentOfRange);
lowerBand:=trimprice(dayOpen-preDayRange*percentOfRange);

enterTime:=time>=09100 and time<=140000;
exitTime:=time>=145000;

longCond:=enterTime and high>=upperBand and not(longStopped);
longPrice:=max(upperBand,open);

shortCond:=enterTime and low<=lowerBand and not(shortStopped);
shortPrice:=min(lowerBand,open);

if holding=0 then begin
 if longCond then begin
  buy(1,1,limitr,longPrice);
  longStopped:=true;
 end 
end

if holding=0 then begin
 if shortCond then begin
  buyshort(1,1,limitr,shortPrice);
  shortStopped:=true;
 end
end

higherAfterEntry:=ref(hhv(high,enterbars),1);
lowerAfterEntry:=ref(llv(low,enterbars),1);

if holding>0 then begin
 if higherAfterEntry>=avgenterprice+dayOpen*trailingStart*0.01 then
  stopline:=higherAfterEntry-dayOpen*trailingStop*0.01;
 else
  stopline:=upperBand-dayOpen*stopLossSet*0.01;
 
 if low<=stopLine then begin
  sell(1,holding,limitr,min(stopLine,open));
  longStopped:=true;  
  shortStopped:=false;
 end 
 
 if time>=exitTime then
  sell(1,holding,limitr,open); 
end

if holding<0 then begin
 if lowerAfterEntry<=avgenterprice-dayOpen*trailingStart*0.01 then
  stopline:=lowerAfterEntry+dayOpen*trailingStop*0.01;
 else
  stopline:=lowerBand+dayOpen*stopLossSet*0.01;
 
 if high>=stopLine then begin
  sellshort(1,holding,limitr,max(stopLine,open));
  shortStopped:=true;
  longStopped:=false;
 end 
 
 if time>=exitTime then
  sellshort(1,holding,limitr,open); 
end
 

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

 回到顶部