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


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

   

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


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

主题:[交易系统]nfs

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


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

runmode:0;

input:entryperiod(1,1,5,1);
input:initialstop(3,2,4,1);
input:breakevenstop(4,2,4,1);
input:trailingstop(5,4,8,1);
input:exitperiod(2,1,5,1);
input:intraday(1,0,1,1);
input:money(0,0,10,1);
input:offset(0,0,2,1);
input:debug(0,0,1,1);

variable:costprice=0;
variable:stopline=0;
variable:myasset=30000;

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,'if')=0 then begin
  marginratio:=15/100;
  commission:=0.6/10000;
  tradeable:=1;
   
  entrytime:=time>=093100 and time<=151400;
  exittime:=time>=151500;
  
  stoplossunit:=25*mindiff;  
  length:=60;
 end else begin
  if stricmp(label,'cf')=0 then begin
   marginratio:=17/100;
   commission:=12;
   tradeable:=1;
  end  
  
  if stricmp(label,'sr')=0 then begin
   marginratio:=18/100;
   commission:=6;
   tradeable:=1;
  end    
   
  entrytime:=time>=091600 and time<=145900;
  exittime:=time>=150000; 
  
  stoplossunit:=5*mindiff;  
  length:=225; 
 end  
end

if tradeable=0 then exit;

if not(datatype=1) then exit;

begin  
 cond:=date>ref(date,1) or barpos=1; 
 dist:=barpos-valuewhen(cond,barpos)+1; 
 averageprice:=trimprice(sum(amount,dist)/sum(vol,dist)/multiplier); 
 settlementprice:=trimprice(sum(amount,length)/sum(vol,length)/multiplier);
  
 entryupperband:=ref(hhv(high,60*entryperiod),1)+mindiff;
 entrylowerband:=ref(llv(low,60*entryperiod),1)-mindiff;
  
 exitupperband:=ref(hhv(high,30*exitperiod),2)+mindiff;
 exitlowerband:=ref(llv(low,30*exitperiod),2)-mindiff; 
 
 initialstopnum:=stoplossunit*initialstop;
 breakevenstopnum:=stoplossunit*breakevenstop;
 trailingstopnum:=stoplossunit*trailingstop;
 offsetnum:=mindiff*offset;
end

if holding=0 then begin 
 myentryprice:=0;
 lots:=0;
 
 if year>=2011 and entrytime and high>=entryupperband then
  myentryprice:=max(open,entryupperband);  
  
 if myentryprice>0 then begin
  mycash:=cash(0);   
  
  if money=0 then begin
   lots:=1;
  end else begin
   lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));   
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end
 
 if lots>=1 then
  buy(1,lots,limitr,myentryprice+offsetnum); 
end

if holding=0 then begin 
 myentryprice:=0;
 lots:=0;
 
 if year>=2011 and entrytime and low<=entrylowerband then
  myentryprice:=min(open,entrylowerband);
  
 if myentryprice>0 then begin
  mycash:=cash(0);   
  
  if money=0 then begin
   lots:=1;
  end else begin
   lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));    
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end
 
 if lots>=1 then
  buyshort(1,lots,limitr,myentryprice-offsetnum); 
end

if holding>0 then begin
 myexitprice:=0;
 
 if exittime then begin
  if intraday=0 then begin
   myexitprice:=open;
  end else begin
   if not(costprice<averageprice and averageprice<stopline) then
    myexitprice:=open; 
  end 
 end
 
 if stopline>0 and low<=stopline then
  myexitprice:=min(open,stopline);
  
 if stopline=0 then begin
  if commission>1 then
   costprice:=enterprice+2*commission/multiplier;
  else
   costprice:=enterprice*(1+commission)/(1-commission);
  
  costprice:=ceiling(costprice/mindiff)*mindiff; 
  
  stopline:=costprice-initialstopnum;
 end 
  
 if stopline<costprice and high-breakevenstopnum>=costprice then
  stopline:=costprice;  
 
 if stopline>=costprice and high-trailingstopnum>stopline then
  stopline:=high-trailingstopnum;  

 if exitlowerband>stopline then
  stopline:=exitlowerband; 
 
 if myexitprice>0 then begin
  sell(1,holding,limitr,myexitprice-offsetnum);
  costprice:=0;
  stopline:=0;
  myasset:=asset;
 end 
end

if holding<0 then begin 
 myexitprice:=0;
 
 if exittime then begin
  if intraday=0 then begin
   myexitprice:=open;
  end else begin
   if not(costprice>averageprice and averageprice>stopline) then
    myexitprice:=open;
  end 
 end 

 if stopline>0 and high>=stopline then
  myexitprice:=max(open,stopline);
  
 if stopline=0 then begin
  if commission>1 then
   costprice:=enterprice-2*commission/multiplier;
  else
   costprice:=enterprice*(1-commission)/(1+commission);
   
  costprice:=floor(costprice/mindiff)*mindiff; 
  
  stopline:=costprice+initialstopnum;
 end 
 
 if stopline>costprice and low+breakevenstopnum<=costprice then
  stopline:=costprice;
    
 if stopline<=costprice and low+trailingstopnum<stopline then
  stopline:=low+trailingstopnum;    
  
 if exitupperband<stopline then
  stopline:=exitupperband;  
 
 if myexitprice>0 then begin
  sellshort(1,holding,limitr,myexitprice+offsetnum);
  costprice:=0;
  stopline:=0;
  myasset:=asset;
 end 
end

保证金:round(close*multiplier*marginratio),linethick0;

partline(1,averageprice,colorblue,2);
partline(entrytime and holding=0,entryupperband,colorred,2);
partline(entrytime and holding=0,entrylowerband,colorgreen,2);

if entrytime and holding=0 then begin
 上轨:entryupperband,linethick0;
 下轨:entrylowerband,linethick0;
end

if holding>0 then begin
 多头成本:costprice,linethick0;
 多头止损:stopline,linethick0;
 多头盈亏:(stopline-costprice)*multiplier,linethick0;
 
 drawicon(stopline<costprice,stopline,11);
 drawicon(stopline=costprice,stopline,12);
 drawicon(stopline>costprice,stopline,10); 
end

if holding<0 then begin
 空头成本:costprice,linethick0;
 空头止损:stopline,linethick0;
 空头盈亏:(costprice-stopline)*multiplier,linethick0;
 
 drawicon(stopline>costprice,stopline,11);
 drawicon(stopline=costprice,stopline,12);
 drawicon(stopline<costprice,stopline,10);  
end

if debug=1 then begin
 资产:myasset,noaxis,linethick2,colormagenta;      
 收益:(myasset-30000)/30000,linethick0;
 次数:totaltrade,linethick0;
 胜率:percentwin,linethick0;
 连亏:maxseqloss,linethick0;
 连赢:maxseqwin,linethick0;
end

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

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


加好友 发短信
等级:新手上路 帖子:87 积分:231 威望:0 精华:0 注册:2011/11/16 13:43:04
  发帖心情 Post By:2013/6/11 23:33:58 [只看该作者]

以下是引用z7c9在2011/8/4 12:57:27的发言:

runmode:0;

input:entryperiod(1,1,5,1);
input:initialstop(3,2,4,1);
input:breakevenstop(4,2,4,1);
input:trailingstop(5,4,8,1);
input:exitperiod(2,1,5,1);
input:intraday(1,0,1,1);
input:money(0,0,10,1);
input:offset(0,0,2,1);
input:debug(0,0,1,1);

variable:costprice=0;
variable:stopline=0;
variable:myasset=30000;

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,'if')=0 then begin
  marginratio:=15/100;
  commission:=0.6/10000;
  tradeable:=1;
   
  entrytime:=time>=093100 and time<=151400;
  exittime:=time>=151500;
  
  stoplossunit:=25*mindiff;  
  length:=60;
 end else begin
  if stricmp(label,'cf')=0 then begin
   marginratio:=17/100;
   commission:=12;
   tradeable:=1;
  end  
  
  if stricmp(label,'sr')=0 then begin
   marginratio:=18/100;
   commission:=6;
   tradeable:=1;
  end    
   
  entrytime:=time>=091600 and time<=145900;
  exittime:=time>=150000; 
  
  stoplossunit:=5*mindiff;  
  length:=225; 
 end  
end

if tradeable=0 then exit;

if not(datatype=1) then exit;

begin  
 cond:=date>ref(date,1) or barpos=1; 
 dist:=barpos-valuewhen(cond,barpos)+1; 
 averageprice:=trimprice(sum(amount,dist)/sum(vol,dist)/multiplier); 
 settlementprice:=trimprice(sum(amount,length)/sum(vol,length)/multiplier);
  
 entryupperband:=ref(hhv(high,60*entryperiod),1)+mindiff;
 entrylowerband:=ref(llv(low,60*entryperiod),1)-mindiff;
  
 exitupperband:=ref(hhv(high,30*exitperiod),2)+mindiff;
 exitlowerband:=ref(llv(low,30*exitperiod),2)-mindiff; 
 
 initialstopnum:=stoplossunit*initialstop;
 breakevenstopnum:=stoplossunit*breakevenstop;
 trailingstopnum:=stoplossunit*trailingstop;
 offsetnum:=mindiff*offset;
end

if holding=0 then begin 
 myentryprice:=0;
 lots:=0;
 
 if year>=2011 and entrytime and high>=entryupperband then
  myentryprice:=max(open,entryupperband);  
  
 if myentryprice>0 then begin
  mycash:=cash(0);   
  
  if money=0 then begin
   lots:=1;
  end else begin
   lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));   
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end
 
 if lots>=1 then
  buy(1,lots,limitr,myentryprice+offsetnum); 
end

if holding=0 then begin 
 myentryprice:=0;
 lots:=0;
 
 if year>=2011 and entrytime and low<=entrylowerband then
  myentryprice:=min(open,entrylowerband);
  
 if myentryprice>0 then begin
  mycash:=cash(0);   
  
  if money=0 then begin
   lots:=1;
  end else begin
   lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));    
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end
 
 if lots>=1 then
  buyshort(1,lots,limitr,myentryprice-offsetnum); 
end

if holding>0 then begin
 myexitprice:=0;
 
 if exittime then begin
  if intraday=0 then begin
   myexitprice:=open;
  end else begin
   if not(costprice<averageprice and averageprice<stopline) then
    myexitprice:=open; 
  end 
 end
 
 if stopline>0 and low<=stopline then
  myexitprice:=min(open,stopline);
  
 if stopline=0 then begin
  if commission>1 then
   costprice:=enterprice+2*commission/multiplier;
  else
   costprice:=enterprice*(1+commission)/(1-commission);
  
  costprice:=ceiling(costprice/mindiff)*mindiff; 
  
  stopline:=costprice-initialstopnum;
 end 
  
 if stopline<costprice and high-breakevenstopnum>=costprice then
  stopline:=costprice;  
 
 if stopline>=costprice and high-trailingstopnum>stopline then
  stopline:=high-trailingstopnum;  

 if exitlowerband>stopline then
  stopline:=exitlowerband; 
 
 if myexitprice>0 then begin
  sell(1,holding,limitr,myexitprice-offsetnum);
  costprice:=0;
  stopline:=0;
  myasset:=asset;
 end 
end

if holding<0 then begin 
 myexitprice:=0;
 
 if exittime then begin
  if intraday=0 then begin
   myexitprice:=open;
  end else begin
   if not(costprice>averageprice and averageprice>stopline) then
    myexitprice:=open;
  end 
 end 

 if stopline>0 and high>=stopline then
  myexitprice:=max(open,stopline);
  
 if stopline=0 then begin
  if commission>1 then
   costprice:=enterprice-2*commission/multiplier;
  else
   costprice:=enterprice*(1-commission)/(1+commission);
   
  costprice:=floor(costprice/mindiff)*mindiff; 
  
  stopline:=costprice+initialstopnum;
 end 
 
 if stopline>costprice and low+breakevenstopnum<=costprice then
  stopline:=costprice;
    
 if stopline<=costprice and low+trailingstopnum<stopline then
  stopline:=low+trailingstopnum;    
  
 if exitupperband<stopline then
  stopline:=exitupperband;  
 
 if myexitprice>0 then begin
  sellshort(1,holding,limitr,myexitprice+offsetnum);
  costprice:=0;
  stopline:=0;
  myasset:=asset;
 end 
end

保证金:round(close*multiplier*marginratio),linethick0;

partline(1,averageprice,colorblue,2);
partline(entrytime and holding=0,entryupperband,colorred,2);
partline(entrytime and holding=0,entrylowerband,colorgreen,2);

if entrytime and holding=0 then begin
 上轨:entryupperband,linethick0;
 下轨:entrylowerband,linethick0;
end

if holding>0 then begin
 多头成本:costprice,linethick0;
 多头止损:stopline,linethick0;
 多头盈亏:(stopline-costprice)*multiplier,linethick0;
 
 drawicon(stopline<costprice,stopline,11);
 drawicon(stopline=costprice,stopline,12);
 drawicon(stopline>costprice,stopline,10); 
end

if holding<0 then begin
 空头成本:costprice,linethick0;
 空头止损:stopline,linethick0;
 空头盈亏:(costprice-stopline)*multiplier,linethick0;
 
 drawicon(stopline>costprice,stopline,11);
 drawicon(stopline=costprice,stopline,12);
 drawicon(stopline<costprice,stopline,10);  
end

if debug=1 then begin
 资产:myasset,noaxis,linethick2,colormagenta;      
 收益:(myasset-30000)/30000,linethick0;
 次数:totaltrade,linethick0;
 胜率:percentwin,linethick0;
 连亏:maxseqloss,linethick0;
 连赢:maxseqwin,linethick0;
end

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


 回到顶部