--  逐k线计算改序列
        
逐k线计算改序列,不知道哪函数通不过?
input:p(10,2,200,1);
input:length(75,10,300,10);
input:zs(4,1,50,1);
input:k1(4,1,50,1);
line:=ma(close,30);
tr1 :=max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low));
atr:=ma(tr1,length); 
zsx:=ifelse(zs*ref(atr,1)<0.01*ref(c,1),0.01*ref(c,1),zs*ref(atr,1));
enterbars1:=enterbars+1;
dstop:=ref(l,1)-k1*ref(atr,1);//实时进多平仓价
kstop:=ref(h,1)+k1*ref(atr,1);//实时进空平仓价
dstop1:hhv(dstop,enterbars1);//平多价
kstop1:llv(kstop,enterbars1);//平空价
//建立多头的进场条件
    long:=cross(open,line);
 
   if long then begin
   tsellshort(tholding<0,0,mkt);
   //sellshort(holding<0,0,limitr ,open+mindiff);
   //sellshort(holding<0,0,marketr);
   tbuy(tholding=0,p,mkt);
   
   //if entrycond then begin
   //buy(holding=0,p, limitr ,open+mindiff);
   //end
   
   //buy(holding=0,p, marketr);
  end
//建立空头的进场条件
  
   short:= cross(line,open) ;
   if short then begin
   tsell(tholding>0,0,mkt);
   //sell(holding>0,0,limitr,open-mindiff);
   //sell(holding>0,0,marketr);
   tbuyshort(tholding=0,p,mkt);
   //if entrycond then begin
   //buyshort(holding=0,p,limitr,open-mindiff);
   //end
   //buyshort(holding=0,p,marketr);
  end
if tholding>0 and c<=max(enterprice-zsx,dstop1) then tsell(1,0,mkt);
if tholding<0 and c>=min(enterprice+zsx,kstop1) then tsellshort(1,0,mkt);