[PEL] 复制代码
INPUT:M(26,5,300,30),N(2,0.1,10,1);
MID : MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);
PX:=VALUEWHEN(TODAYBAR=1,L);//第一个K的最低价
PY:=VALUEWHEN(TODAYBAR=1,H);//第一个K的最高价
P1:VALUEWHEN(BARSSINCE2(CROSS(PX,UPPER),TODAYBAR)=0,C);//当日第一次满足条件时候的收盘价
P2:VALUEWHEN(BARSSINCE2(CROSS(H,PY),TODAYBAR)=0,C);
if cross(MID,P1) then buy(holding=0,1,market);//当中轨突破P1时候 开多
if cross(P2,MID) then buyshort(holding=0,1,market);
abb:=timetot0(CLOSETIME(0))-time0,NODRAW;//当前K线时间距离收盘K线结束倒计时
abb3:=timetot0(CLOSETIME(0))-timetot0(dynainfo(207)),NODRAW;//当前时间距离收盘K时间
IF (abb<N*60 and abb>=0 and (not(ISLASTBAR))) or (ISLASTBAR and abb3>=0 and abb3<N*60) THEN //兼顾实际交易时候的信号和历史回测信号
begin
sell(holding>0,holding,market);
sellshort(holding<0,holding,market);
end
持仓:HOLDING; |