// 三背离出击副图指标
// MACD参数设定
MACD_DIFF := EMA(CLOSE, 12) - EMA(CLOSE, 26);
MACD_DEA := EMA(MACD_DIFF, 9);
MACD_MACD := MACD_DIFF - MACD_DEA;
// RSI参数设定
RSI_N := 14;
RSI := 100 * SMA(IF(CLOSE > REF(CLOSE, 1), CLOSE - REF(CLOSE, 1), 0), RSI_N) /
(SMA(ABS(CLOSE - REF(CLOSE, 1)), RSI_N));
// KDJ参数设定
KDJ_N := 14;
RSV := 100 * (CLOSE - LLV(LOW, KDJ_N)) / (HHV(HIGH, KDJ_N) - LLV(LOW, KDJ_N));
K := SMA(RSV, 3, 1);
D := SMA(K, 3, 1);
J := 3 * K - 2 * D;
// 背离信号判断
背离信号 := (CROSS(MACD_DIFF, 0) AND (MACD_DIFF < 0) AND (RSI < 30)) OR
(CROSS(0, MACD_DIFF) AND (MACD_DIFF > 0) AND (RSI > 70));
// 绘制指标
DRAWBAND(MACD_DIFF, "MACD", RED);
DRAWBAND(RSI, "RSI", GREEN);
DRAWBAND(J, "KDJ", BLUE);
IF(背离信号, DRAWICON(0, 0, '↑', YELLOW));