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


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

   

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


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

主题:[交易系统]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编辑过]

 回到顶部