以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  交易策略发布专区  (http://weistock.com/bbs/list.asp?boardid=10)
----  [交易系统]DTS  (http://weistock.com/bbs/dispbbs.asp?boardid=10&id=7525)

--  作者:z7c9
--  发布时间:2011/8/14 13:00:48
--  [交易系统]DTS

runmode:0;

input:money(0,0,5,1);
input:ratio(2,1,10,1);

variable:trend=0;
variable:callback=0;
variable:stoplossprice=0;
variable:takeprofitprice=0;
variable:daytradecounter=0;

if day>ref(day,1) then begin
 callback:=0;
 daytradecounter:=0;
 
 if close=open then
  trend:=0;
  
 if close>open then
  trend:=1;
  
 if close<open then
  trend:=-1; 
end

if trend=0 then begin
 if close>open then
  trend:=1;
 
 if close<open then
  trend:=-1; 
end

dist:=barslast(day>ref(day,1))+1;

highest:=ref(hhv(high,dist),1);
lowest:=ref(llv(low,dist),1);

if trend=1 and low<=lowest then
 trend:=-1;
 
if trend=-1 and high>=highest then
 trend:=1; 

dist1:=barslast(high<ref(high,1) and low<ref(low,1));
stoplossprice1:=ref(low,dist1);

dist2:=barslast(high>ref(high,1) and low>ref(low,1));
stoplossprice2:=ref(high,dist2);

if trend=1 and ref(high,1)<ref(high,3) and ref(high,2)<ref(high,3)  and ref(high,3)=highest then
 callback:=1;

if trend=-1 and ref(low,1)>ref(low,3) and ref(low,2)>ref(low,3)  and ref(low,3)=lowest then
 callback:=-1;
 
if holding=0 then begin
 myentryprice:=0;
 lots:=0;
 
 if daytradecounter=0 and dist>=4 and trend=1 and callback=1 and high>=highest+mindiff then 
  myentryprice:=max(open,highest+mindiff);  
 
 if myentryprice>0 then  begin 
  if dist1<=dist then
   stoplossprice:=stoplossprice1;
  else
   stoplossprice:=lowest;
   
  initialstopnum:=myentryprice-stoplossprice; 
  
  takeprofitprice:=myentryprice+initialstopnum*ratio;
    
  if money=0 then begin
   lots:=1;
  end else begin
   mycash:=cash(0);
   lots1:=intpart(mycash/(myentryprice*multiplier*taccount(41)));
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end 
  
 if lots>=1 then begin
  buy(1,lots,limitr,myentryprice);
  daytradecounter:=1;
 end 
end  

if holding=0 then begin
 myentryprice:=0;
 lots:=0;
 
 if daytradecounter=0 and dist>=4 and trend=-1 and callback=-1 and low<=lowest-mindiff then 
  myentryprice:=min(open,lowest-mindiff);  
 
 if myentryprice>0 then  begin 
  if dist2<=dist then
   stoplossprice:=stoplossprice2;
  else
   stoplossprice:=highest;
   
  initialstopnum:=stoplossprice-myentryprice; 
  
  takeprofitprice:=myentryprice-initialstopnum*ratio;
    
  if money=0 then begin
   lots:=1;
  end else begin
   mycash:=cash(0);
   lots1:=intpart(mycash/(myentryprice*multiplier*taccount(41)));
   lots2:=intpart(mycash*(money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
  end
 end 
  
 if lots>=1 then begin
  buyshort(1,lots,limitr,myentryprice);
  daytradecounter:=1;
 end 
end

if holding>0 then begin
 myexitprice:=0;
 lots:=holding;
 
 if stricmp(marketlabel,\'zj\')=0 then begin
  if time>=151500 then
   myexitprice:=open;
 end else begin
  if time>=150000 then
   myexitprice:=open;
 end 
 
 if high>=takeprofitprice then
  myexitprice:=max(open,takeprofitprice);
 
 if low<=stoplossprice then
  myexitprice:=min(open,stoplossprice); 
  
 if myexitprice>0 then  
  sell(1,lots,limitr,myexitprice);
end

if holding<0 then begin
 myexitprice:=0;
 lots:=-holding;
 
 if stricmp(marketlabel,\'zj\')=0 then begin
  if time>=151500 then
   myexitprice:=open;
 end else begin
  if time>=150000 then
   myexitprice:=open;
 end 
 
 if low<=takeprofitprice then
  myexitprice:=min(open,takeprofitprice);
  
 if high>=stoplossprice then
  myexitprice:=max(open,stoplossprice); 
   
 if myexitprice>0 then  
  sellshort(1,lots,limitr,myexitprice);
end

drawicon(holding<>0,stoplossprice,11);
drawicon(holding<>0,takeprofitprice,10);

资产:asset,noaxis,linethick2;

 

 

图片点击可在新窗口打开查看 


--  作者:xian_0_9
--  发布时间:2011/8/15 20:10:33
--  
图片点击可在新窗口打开查看
--  作者:liyuanhao
--  发布时间:2015/2/20 11:46:55
--  
variable:trend=0;此句有问题