[PEL] 复制代码
vv:=10;
sth:=ref(h,2)>ref(h,3)&&ref(h,2)>=ref(h,1)&&ref(h,2)>=h;
stl:=ref(l,2)<ref(l,3)&&ref(l,2)<=ref(l,1)&&ref(l,2)<=l;
ee:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&ref(l,2)<valuewhen(stl,ref(l,2));
ff:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&ref(h,2)>valuewhen(sth,ref(h,2));
eex:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&stl&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&ref(l,2)<ref(valuewhen(stl,ref(l,2)),1);
ffx:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&sth&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&ref(h,2)>ref(valuewhen(sth,ref(h,2)),1);
eep:=c>valuewhen(ee||eex,valuewhen(sth,ref(h,2)))+mindiff&&count(c>valuewhen(ee||eex,valuewhen(sth,ref(h,2)))+mindiff,barslast(ee||eex))=1;
ffp:=c<valuewhen(ff||ffx,valuewhen(stl,ref(l,2)))-mindiff&&count(c<valuewhen(ff||ffx,valuewhen(stl,ref(l,2)))-mindiff,barslast(ff||ffx))=1;
kd:=ff||ffx;//开多条件
pd:=ffp; //平多反手
mk:=ee||eex;//开空条件
pk:=eep; //平空反手
tcon:time>130000 and time<=185500;//时间大于北京时间9点(金字塔时间130000),小于145500(金字塔时间185500)
//有空头时候才触发反手
if pk and holding<0 then
begin
sellshort(kd,holding,market);
反手开多:buy(tcon,vv,market);
end
buy(kd and holding=0 and tcon,vv,market);
//有多头时候才触发反手
if pd and holding>0 then
begin
sell(mk,holding,market);
buyshort(tcon,vv,market);
end
buyshort(mk and holding=0 and tcon,vv,market); //开空信号
多止损:sell(c<avgenterprice-10*mindiff,holding,market);
空止损:sellshort(c>avgenterprice+10*mindiff,holding,market);
H1:=HHV(H,ENTERBARS+1);//开仓后最高价
L1:=LLV(L,ENTERBARS+1);
maxprofit:if(holding>0,h1-AVGENTERPRICE,AVGENTERPRICE-l1);//开仓后最大盈利(价差)
currentprofit:if(holding>0,c-AVGENTERPRICE,AVGENTERPRICE-c);//当前浮动盈亏(价差)
if maxprofit>=15*MINDIFF and currentprofit<maxprofit*0.7 and ENTERBARS>=0 then
begin
回撤平多:sell(1,holding,market);
回撤平空:sellshort(1,holding,market);
end
tq:=60*5;//提前的秒数
abb:=remainingtime(closetime(0))<=tq;
if abb then begin
收盘平多:sell(1,holding,market);
收盘平空:sellshort(1,holding,market);
end