input:m1(10,1,100,2),n(1.2,0.1,20,1),n1(2,0.1,20,1),m(9,1,20,1),s(13,1,20,1),p(26,1,30,1),n2(3,1,20,1),n3(5,1,20,1),n4(7,0.1,20,1);
BBI:=(MA(CLOSE,3)+MA(CLOSE,6)+MA(CLOSE,12)+MA(CLOSE,24))/4;
UPR:=BBI+N*ema(tr,M1);
DWN:=BBI-N*ema(tr,M1);
c1:=ref(c,1);
DIFF := EMA(CLOSE,S) - EMA(CLOSE,P);
DEA := EMA(DIFF,M);
MACD1 := 2*(DIFF-DEA);
macd2:=ref(macd1,1);
hhv1hh:=STKINDI('','wwma.hhv1h',0,5);
llv1hh:=STKINDI('','wwma.llv1h',0,5);
h1:=hour;
h2:=ref(hour,30);
平空条件:=h1=h2;
if holding<>0 then BEGIN;
SELLSHORT(平空条件,0,MARKET);
end;
max0:=ma(c,n2);
max1:=ref(ma(c,n2),1);
mad0:=ma(c,n3);
mad1:=ref(ma(c,n3),1);
cys:=count(cross(ma(c,n2),ma(c,n3)) or cross(ma(c,n3),ma(c,n2)),n4);
开空条件1:=macd1<ref(macd1,1) and ref(macd1,1)<ref(macd1,2) and ref(macd1,2)<ref(macd1,3);
开空条件2:=C>BBI;
开空条件3:=C>BBI;
a1:=macd1<macd2;
if holding=0 and max0>mad0 and cys=0 then begin;
sell(开空条件1,1,MARKET);
end;
if holding=0 and max0<mad0 and cys=0 then begin;
sell(开空条件2 and a1,1,MARKET);
end;
if holding=0 and cys>0 then BEGIN;
sell(开空条件3 and a1,1,MARKET);
end;
持仓:=holding;