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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → [交易系统]TurtleTradingSystem

   

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


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

主题:[交易系统]TurtleTradingSystem

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


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
[交易系统]TurtleTradingSystem  发帖心情 Post By:2011/6/11 14:33:40 [只看该作者]

runmode:0;

input:riskratio(1,0,2,1);
input:atrlength(20,5,40,5);
input:period1(20,5,60,5);
input:period2(55,5,60,5);
input:period3(10,5,60,5);

variable:times:=0;

if barpos=1 then begin
 preenteryprice:=0;
 prebreakoutfailure:=false;
end

if barpos<=period1 then exit;
if date<1110104 then exit;

begin
 if stricmp(marketlabel,'sq')=0 then
  label:=strleft(stklabel,2);
   
 if stricmp(marketlabel,'dq')=0 then
  label:=strleft(stklabel,1);
 
 if stricmp(marketlabel,'zq')=0 then
  label:=strleft(stklabel,2); 
  
 if stricmp(marketlabel,'zj')=0 then
  label:=strleft(stklabel,2);
  
 if stricmp(label,'cf')=0 then begin
  marginratio:=0.17;
  commission:=12;
  tradeable:=true;
 end
 
 if not(tradeable) then exit;
end     

begin
 atr:=trimprice(ref(ma(tr,atrlength),1));
 
 topband1:=ref(hhv(high,period1),1)+mindiff;
 botband1:=ref(llv(low,period1),1)-mindiff;
 
 topband2:=ref(hhv(high,period2),1)+mindiff;
 botband2:=ref(llv(low,period2),1)-mindiff; 
 
 topband3:=ref(hhv(high,period3),1)+mindiff;
 botband3:=ref(llv(low,period3),1)-mindiff;
 
 enterlongcond1:=high>=topband1;
 enterlongprice1:=max(open,topband1);
 
 entershortcond1:=low<=botband1;
 entershortprice1:=min(open,botband1);
 
 enterlongcond2:=high>=topband2;
 enterlongprice2:=max(open,topband2);
 
 entershortcond2:=low<=botband2;
 entershortprice2:=min(open,botband2);
 
 exitlongcond:=low<=botband3;
 exitlongprice:=min(open,botband3);
 
 exitshortcond:=high>=topband3;
 exitshortprice:=max(open,topband3);
end 

if holding=0 then begin
 price:=0;
 lots:=0;
 
 if enterlongcond1 and prebreakoutfailure then
  price:=enterlongprice1;
 
 if enterlongcond2 then
  price:=enterlongprice2; 
 
 if price>0 then begin  
  mycash:=cash(0);
  
  lots1:=intpart(mycash/(price*multiplier*marginratio));   
  
  if riskratio=0 then begin
   lots:=lots1;
  end else begin
   lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier));
   lots:=min(lots1,lots2);
  end
 end  
  
 if lots>=1 then begin
  buy(1,lots,limitr,price);
  times:=1;
  prebreakoutfailure:=false;
 end 
end

if holding=0 then begin
 price:=0;
 lots:=0;
 
 if entershortcond1 and prebreakoutfailure then
  price:=entershortprice1;
 
 if entershortcond2 then
  price:=entershortprice2; 
 
 if price>0 then begin  
  mycash:=cash(0);
  
  lots1:=intpart(mycash/(price*multiplier*marginratio));   
  
  if riskratio=0 then begin
   lots:=lots1;
  end else begin
   lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier));
   lots:=min(lots1,lots2);
  end
 end  
  
 if lots>=1 then begin
  buyshort(1,lots,limitr,price);
  times:=1;
  prebreakoutfailure:=false;
 end 
end

if holding>0 then begin 
 while high>=enterprice+0.5*atr and times<=4 do begin    
  price:=max(open,enterprice+0.5*atr);
  lots:=0;   
  
  if price>0 then begin  
   mycash:=cash(0);
   
   lots1:=intpart(mycash/(price*multiplier*marginratio));   
   
   if riskratio=0 then begin
    lots:=lots1;
   end else begin
    lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier));
    lots:=min(lots1,lots2);
   end
  end  
   
  if lots>=1 then begin
   buy(1,lots,limitr,price);
   times:=times+1;
  end 
 end
 
 price:=0;
 
 if exitlongcond then
  price:=exitlongprice;
 
 if low<=enterprice-2*atr and enterbars<>0 then begin
  price:=min(open,enterprice-2*atr);
  prebreakoutfailure:=true;
 end 
 
 if price>0 then
  sell(1,holding,limitr,price);   
end

if holding<0 then begin
 while low<=enterprice-0.5*atr and times<=4 do begin
   
  price:=min(open,enterprice-0.5*atr);
  lots:=0;   
  
  if price>0 then begin  
   mycash:=cash(0);
   
   lots1:=intpart(mycash/(price*multiplier*marginratio));   
   
   if riskratio=0 then begin
    lots:=lots1;
   end else begin
    lots2:=intpart(mycash*0.01*riskratio/(atr*multiplier));
    lots:=min(lots1,lots2);
   end
  end  
   
  if lots>=1 then begin
   buyshort(1,lots,limitr,price);
   times:=times+1;
  end 
 end
 
 price:=0;
 
 if exitshortcond then
  price:=exitshortprice;
  
 if high>=enterprice+2*atr and enterbars<>0 then begin
  price:=max(open,enterprice+2*atr); 
  prebreakoutfailure:=true;
 end 
  
 if price>0 then
  sellshort(1,holding,limitr,price);  
end

[此贴子已经被作者于2011-10-3 11:20:53编辑过]

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


加好友 发短信
等级:新手上路 帖子:86 积分:427 威望:0 精华:0 注册:2010/5/5 10:39:30
  发帖心情 Post By:2011/6/19 0:24:10 [只看该作者]

为何没有信号呢?


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


加好友 发短信
等级:论坛游民 帖子:191 积分:491 威望:0 精华:0 注册:2011/5/29 11:19:11
  发帖心情 Post By:2011/7/11 8:07:53 [只看该作者]

怎么导入金字塔呀 请指点 谢谢

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


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2011/9/18 10:31:34 [只看该作者]

runmode:0;

input:riskratio(1,0,2,1);
input:atrlength(20,5,30,5);
input:entryperiod(20,5,60,5);
input:exitperiod(10,5,60,5);

variable:times=0;

atr:=ref(ma(tr,atrlength),1);
marginratio:=10/100;

entryupperband:=ref(hhv(high,entryperiod),1)+mindiff;
entrylowerband:=ref(llv(low,entryperiod),1)-mindiff;

exitupperband:=ref(hhv(high,exitperiod),1)+mindiff;
exitlowerband:=ref(llv(low,exitperiod),1)-mindiff;

entrylongcond:=high>=entryupperband;
entryshortcond:=low<=entrylowerband;

exitlongcond:=low<=exitlowerband;
exitshortcond:=high>=exitupperband;

if holding=0 then begin
 price:=0;
 lots:=0;
 
 if entrylongcond then
  price:=max(open,entryupperband);
  
 if price>0 then begin
  mycash:=cash(0);
  
  lots1:=intpart(mycash/(price*multiplier*marginratio));
  lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
  lots:=max(1,min(lots1,lots2));
 end 
 
 if lots>=1 then begin
  buy(1,lots,limitr,price);
  times:=1;
 end
end

if holding>0 then begin
 while high>=enterprice+atr/2 and times<4 do begin
  price:=max(open,enterprice+atr/2);
  lots:=0;
  
  if price>0 then begin
   mycash:=cash(0);
   
   lots1:=intpart(mycash/(price*multiplier*marginratio));
   lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
   lots:=max(1,min(lots1,lots2));
  end
  
  if lots>=1 then begin
   buy(1,lots,limitr,price);
   times:=times+1;
  end
 end
end

if holding=0 then begin
 price:=0;
 lots:=0;
 
 if entryshortcond then
  price:=min(open,entrylowerband);
  
 if price>0 then begin
  mycash:=cash(0);
  
  lots1:=intpart(mycash/(price*multiplier*marginratio));
  lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
  lots:=max(1,min(lots1,lots2));
 end 
 
 if lots>=1 then begin
  buyshort(1,lots,limitr,price);
  times:=1;
 end
end

if holding<0 then begin
 while low<=enterprice-atr/2 and times<4 do begin
  price:=min(open,enterprice-atr/2);
  lots:=0;
  
  if price>0 then begin
   mycash:=cash(0);
   
   lots1:=intpart(mycash/(price*multiplier*marginratio));
   lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
   lots:=max(1,min(lots1,lots2));
  end
  
  if lots>=1 then begin
   buyshort(1,lots,limitr,price);
   times:=times+1;
  end
 end
end

if holding>0 then begin
 price:=0;
 
 if exitlongcond then
  price:=min(open,exitlowerband);
  
 if low<=enterprice-2*atr and enterbars>=1 then
  price:=min(open,enterprice-2*atr);
  
 if price>0 then
  sell(1,holding,limitr,price); 
end

if holding<0 then begin
 price:=0;
 
 if exitshortcond then
  price:=max(open,exitupperband);
 
 if high>=enterprice+2*atr and enterbars>=1 then
  price:=max(open,enterprice+2*atr);
  
 if price>0 then
  sellshort(1,holding,limitr,price);
end

盈亏:asset-500000,noaxis,colorred,linethick2;


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


加好友 发短信
等级:新手上路 帖子:80 积分:277 威望:0 精华:0 注册:2011/2/14 21:50:41
  发帖心情 Post By:2011/9/18 22:13:12 [只看该作者]

 

哪个高手,能够加上注释那就好极了!


 回到顶部