[PEL] 复制代码 variable:h1:=0,l1:=0;
n:=10;
x:=15*mindiff;
hx:=hhv(h,n);
lx:=llv(l,n);
if barpos>=n and h1=0 and l1=0 then
begin
h1:=hx;
l1:=lx;
end
if l<=h1-x and h1<>0 AND barpos>n then
begin
if holding>0 then
begin
h1:=h;
l1:=l;
end
sell(1,holding,market);
buyshort(holding=0,1,market);
end
if H>=l1+x and l1<>0 AND barpos>n and (TYPEBAR(1,0)>0 or TYPEBAR(1,0)=-1) then
begin
if holding<0 then
begin
h1:=h;
l1:=l;
end
sellshort(1,holding,market);
buy(holding=0,1,market);
end
if h1<>0 and h>h1 and holding<>0 then h1:=h;
if l1<>0 and l<l1 and holding<>0 then l1:=l;
show_h:IF(h1,H1,DRAWNULL);
show_l:IF(L1,L1,DRAWNULL);
hd:holding;
因为图表模型单个策略内部是不能锁仓的,所以上面代码是按照 平多开空,平空开多设计的。
|