DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
A2:=IF(CROSS(diff,dea) and diff > 0 and dea >0,0,1);
能量线:IF (A2,A1/10,A1/100);
Var1:=EMA(MA(IF(CLOSE>OPEN,(CLOSE-OPEN)*VOL,IF(CLOSE
Var5:=EMA(MA(IF(CLOSEREF(CLOSE,1),(REF(CLOSE,1)-CLOSE)*VOL,0)),10),1);
Var6:=EMA(MA(IF(OPENREF(CLOSE,1),(REF(CLOSE,1)-OPEN)*VOL,0)),10),1);
DX:=(Var1+Var2+Var3)/3/100;
CX:=(Var4+Var5+Var6)/3/100;
B1:=BARSLAST(REF(CROSS(DX,CX),1));
买:IF (CROSS(DX,CX) AND 能量线 >0.5 and 能量线 < 2 and diff > REF(diff,1) AND B1 >5,0,-7);
{卖:IF(A1>2 ,-7,0);}
Sar1:=(CLOSE-LLV(LOW,20))/(HHV(HIGH,20)-LLV(LOW,20))*100;
Sar2:=SMA(SMA(Sar1,3,1),3,1);
Sar3:=EMA(Sar2,5);
Sar4:=3*Sar2-2*Sar3;
Sar5:=IF(Sar4 < REF(Sar4,1),1,0);
buyp:=REF(CLOSE,BARSLAST(REF(买=0,1)))*1.07;
buyk:=REF(CLOSE,BARSLAST(REF(买=0,1)))*0.9;
buyd:=BARSLAST(REF(买=0,1));
卖1:=IF( HIGH > buyp and 买=-7,1,0);{已获利}
卖2:=IF(Sar5 and 买=-7,1,0);{注意顶部}
卖3:=IF(buyd > 10 and 买=-7 ,1,0);{超出短线操作持股天数}
卖4:=IF(LOW < buyk and 买=-7,1,0);{听天由命吧~已亏损10%}
x11:=买=0;
x12:=卖1=1;
a11:=BARSLAST(买=0);{买成立到现在的周期数}
x13:=IF(卖1=1 Or 卖2=1 Or 卖3=1 Or 卖4=1,1,0);
a12:=COUNT(x13=1,a11);
s1:DRAWTEXT(卖1=1 and a12=2,1,'已获利'),COLORRED;
s2:DRAWTEXT(卖1=0 and 卖2=1 and a12=2,1,'注意顶部'),COLORRED;
s3:DRAWTEXT(卖1=0 and 卖2=0 and 卖3=1 and a12=2,1,'超出持股天数'),COLORRED;
s4:DRAWTEXT(卖1=0 and 卖2=0 and 卖3=0 and 卖4=1 and a12=2,1,'止损'),COLORGREEN;