DIFF :=EMA(CLOSE,12) – EMA(CLOSE,26);
DEA := EMA(DIFF,9);
MACD:=2*(DIFF-DEA),COLORSTICK;
UPCOND:=CROSS(DIFF,DEA);
DOWNCOND:=CROSSDOWN(DIFF,DEA);
END_N1:=SUMBARS(DOWNCOND,1);
RANGE_N1:=REF(SUMBARS(UPCOND,1),END_N1);
END_N2:=SUMBARS(DOWNCOND,2);
HH1:=REF(HV(H,RANGE_N1),END_N1-1);
HH2:=REF(HV(H,RANGE_N1),END_N2-1);
MACD1:=REF(REF(MACD,HHVBARS(H,RANGE_N1)),END_N1-1);
MACD2:=REF(REF(MACD,HHVBARS(H,RANGE_N1)),END_N2-1);
顶背离:=CROSS(MACD,0) && HH1>HH2 && MACD1<MACD2;
END_M1:=SUMBARS(UPCOND,1);
RANGE_M1:=REF(SUMBARS(DOWNCOND,1),END_M1);
END_M2:=SUMBARS(UPCOND,2);
LL1:=REF(LV(L,RANGE_M1),END_M1-1);
LL2:=REF(LV(L,RANGE_M1),END_M2-1);
MACD3:=REF(REF(MACD,LLVBARS(L,RANGE_M1)),END_M1-1);
MACD4:=REF(REF(MACD,LLVBARS(L,RANGE_M1)),END_M2-1);
底背离:=CROSSDOWN(MACD,0) && LL1<LL2 && MACD3>MACD4;
#IMPORT[HOUR,1,AB] AS VAR
Q1:=VAR.顶背离;
Q2:=VAR.底背离;
DIFF :=EMA(CLOSE,12) – EMA(CLOSE,26);
DEA := EMA(DIFF,9);
MACD:=2*(DIFF-DEA),COLORSTICK;
UPCOND:=CROSS(DIFF,DEA);
DOWNCOND:=CROSSDOWN(DIFF,DEA);
Q1&&DOWNCOND&&DIFF>0&&SKVOL=0,SK(1);
CROSSDOWN(C,MA(C,20))&&SKVOL>0,SK(1);
Q2&&UPCOND&&DIFF<0&&BKVOL=0,BK(1);
CROSS(C,MA(C,20))&&BKVOL>0,BK(1);
CROSSDOWN(DIFF,DEA),SP(BKVOL);
CROSS(DIFF,DEA),BP(SKVOL);
TRADE_OTHER('AUTO');
(来源:文华财经)