--  作者:z7c9 
        --  发布时间:2011/11/1 13:39:11 
        
        --  [交易系统]两仪四象 
        runmode:0; 
  input:length(20); 
  variable:stopline=0; 
  if barpos<=30 then exit; 
  up:=count(close>ref(close,1),length);  down:=count(close  entrylongcond:=up/down>=2/3;  entryshortcond:=down/up>=2/3; 
  upperband:=ref(hhv(high,length),1);  lowerband:=ref(llv(low,length),1); 
  hh:=ref(high,1);  ll:=ref(low,1); 
  if holding=0 then begin  if ref(entrylongcond,1) then begin  buy(1,1,limitr,open);  stopline:=lowerband;  end 
  if ref(entryshortcond,1) then begin  buyshort(1,1,limitr,open);  stopline:=upperband;  end  end 
  if holding>0 and enterbars>=1 then begin  //if lowerband>stopline then  stopline:=lowerband; 
  if low<=stopline then  sell(1,holding,limitr,min(open,stopline));  end 
  if holding<0 and enterbars>=1 then begin  //if upperband stopline:=upperband; 
  if high>=stopline then  sellshort(1,holding,limitr,max(open,stopline));  end 
  ss:stopline,linethick0;  drawicon(holding<>0,stopline,11);  盈亏:asset-500000,noaxis,coloryellow,linethick2;  
         
       |