程序化指标量化公振指标公式源码
发布日期: 2025-08-27 | 阅读量:29
上升1 := C > REF(C,1) AND C > REF(C,2);
上升2 := REF(上升1,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升3 := REF(上升2,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升4 := REF(上升3,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升5 := REF(上升4,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升6 := REF(上升5,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升7 := REF(上升6,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升8 := REF(上升7,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升9 := REF(上升8,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升A := REF(上升9,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升B := REF(上升A,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升C := REF(上升B,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降1 := C < REF(C,1) AND C < REF(C,2);
下降2 := REF(下降1,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降3 := REF(下降2,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降4 := REF(下降3,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降5 := REF(下降4,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降6 := REF(下降5,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降7 := REF(下降6,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降8 := REF(下降7,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降9 := REF(下降8,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降A := REF(下降9,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降B := REF(下降A,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降C := REF(下降B,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降D := REF(下降C,1) AND C >= REF(C,1) AND C <= REF(C,2);
主升持股 := 上升1 OR 上升2 OR 上升3 OR 上升4 OR 上升5 OR 上升6 OR 上升7 OR 上升8 OR 上升9 OR 上升A OR 上升B OR 上升C;
短买 := REF(下降1 OR 下降2 OR 下降3 OR 下降4 OR 下降5 OR 下降6 OR 下降7 OR 下降8 OR 下降9 OR 下降A OR 下降B OR 下降C OR 下降D, 1) AND 上升1;
品红离场 := REF(上升1 OR 上升2 OR 上升3 OR 上升4 OR 上升5 OR 上升6 OR 上升7 OR 上升8 OR 上升9 OR 上升A OR 上升B OR 上升C, 1) AND 下降1;
离场 := IF(主升持股, LLV(L,2), DRAWNULL), COLOR8000FF, LINETHICK4;
共振线 := (MA(C,3) + MA(C,6) + MA(C,12) + MA(C,24)) / 4, COLORRED, LINETHICK2;
均线20 := MA(C,20);
DRAWBAND(共振线, RGB(155,50,50), 均线20, RGB(0,100,50));
IF(共振线 < 均线20 OR C < 共振线, 共振线, DRAWNULL), COLORBLUE, LINETHICK2;
{--- 拉升线与下跌线 ---}
拉升线: IF(共振线 > 均线20, 均线20, DRAWNULL), COLORMAGENTA, LINETHICK3;
下跌线: IF(共振线 <= 均线20, 均线20, DRAWNULL), COLORBLUE, LINETHICK2;
STICKLINE(C < 共振线, C, O, 3, 0), COLORBLUE;
STICKLINE(C < 共振线, H, L, 0, 0), COLORBLUE;
STICKLINE(C >= 共振线, C, O, 3, 0), COLORYELLOW;
STICKLINE(C >= 共振线, H, L, 0, 0), COLORYELLOW;
STICKLINE(C >= 共振线 AND C > O, C, O, 3, 0), COLORRED;
{--- 三重动量判断 ---}
短动量 := EMA((C*2 + H)/3, 5) > EMA((O*2 + H)/3, 5);
中动量 := ((C + H + L + O)/4 - EMA((C + H + L + O)/4, 13)) > 0;
长趋势 := (EMA(C,12) - EMA(C,26)) > 0;
共振 := 短动量 AND 中动量 AND 长趋势;
DRAWICON(CROSS(共振, 0.5), L, 9);
DRAWTEXT(CROSS(共振, 0.5), L, '★量化共振'), COLORYELLOW;
DRAWICON(品红离场, H, 35); { 向下箭头 }
DRAWICON(短买 AND C > REF(L,1) AND L < REF(C,1), L, 1); { 向上箭头 }
RSI6 := SMA(MAX(C-REF(C,1),0),6,1) / SMA(ABS(C-REF(C,1)),6,1) * 100;
DRAWTEXT(CROSS(80, RSI6), H, '★短跑'), COLORFFDDEE;
DRAWTEXT(CROSS(RSI6, 20), L, '★机会'), COLORRED;

上升2 := REF(上升1,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升3 := REF(上升2,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升4 := REF(上升3,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升5 := REF(上升4,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升6 := REF(上升5,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升7 := REF(上升6,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升8 := REF(上升7,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升9 := REF(上升8,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升A := REF(上升9,1) AND C >= REF(C,2) AND C <= REF(C,1);
上升B := REF(上升A,1) AND C >= REF(C,1) AND C <= REF(C,2);
上升C := REF(上升B,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降1 := C < REF(C,1) AND C < REF(C,2);
下降2 := REF(下降1,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降3 := REF(下降2,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降4 := REF(下降3,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降5 := REF(下降4,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降6 := REF(下降5,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降7 := REF(下降6,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降8 := REF(下降7,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降9 := REF(下降8,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降A := REF(下降9,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降B := REF(下降A,1) AND C >= REF(C,1) AND C <= REF(C,2);
下降C := REF(下降B,1) AND C >= REF(C,2) AND C <= REF(C,1);
下降D := REF(下降C,1) AND C >= REF(C,1) AND C <= REF(C,2);
主升持股 := 上升1 OR 上升2 OR 上升3 OR 上升4 OR 上升5 OR 上升6 OR 上升7 OR 上升8 OR 上升9 OR 上升A OR 上升B OR 上升C;
短买 := REF(下降1 OR 下降2 OR 下降3 OR 下降4 OR 下降5 OR 下降6 OR 下降7 OR 下降8 OR 下降9 OR 下降A OR 下降B OR 下降C OR 下降D, 1) AND 上升1;
品红离场 := REF(上升1 OR 上升2 OR 上升3 OR 上升4 OR 上升5 OR 上升6 OR 上升7 OR 上升8 OR 上升9 OR 上升A OR 上升B OR 上升C, 1) AND 下降1;
离场 := IF(主升持股, LLV(L,2), DRAWNULL), COLOR8000FF, LINETHICK4;
共振线 := (MA(C,3) + MA(C,6) + MA(C,12) + MA(C,24)) / 4, COLORRED, LINETHICK2;
均线20 := MA(C,20);
DRAWBAND(共振线, RGB(155,50,50), 均线20, RGB(0,100,50));
IF(共振线 < 均线20 OR C < 共振线, 共振线, DRAWNULL), COLORBLUE, LINETHICK2;
{--- 拉升线与下跌线 ---}
拉升线: IF(共振线 > 均线20, 均线20, DRAWNULL), COLORMAGENTA, LINETHICK3;
下跌线: IF(共振线 <= 均线20, 均线20, DRAWNULL), COLORBLUE, LINETHICK2;
STICKLINE(C < 共振线, C, O, 3, 0), COLORBLUE;
STICKLINE(C < 共振线, H, L, 0, 0), COLORBLUE;
STICKLINE(C >= 共振线, C, O, 3, 0), COLORYELLOW;
STICKLINE(C >= 共振线, H, L, 0, 0), COLORYELLOW;
STICKLINE(C >= 共振线 AND C > O, C, O, 3, 0), COLORRED;
{--- 三重动量判断 ---}
短动量 := EMA((C*2 + H)/3, 5) > EMA((O*2 + H)/3, 5);
中动量 := ((C + H + L + O)/4 - EMA((C + H + L + O)/4, 13)) > 0;
长趋势 := (EMA(C,12) - EMA(C,26)) > 0;
共振 := 短动量 AND 中动量 AND 长趋势;
DRAWICON(CROSS(共振, 0.5), L, 9);
DRAWTEXT(CROSS(共振, 0.5), L, '★量化共振'), COLORYELLOW;
DRAWICON(品红离场, H, 35); { 向下箭头 }
DRAWICON(短买 AND C > REF(L,1) AND L < REF(C,1), L, 1); { 向上箭头 }
RSI6 := SMA(MAX(C-REF(C,1),0),6,1) / SMA(ABS(C-REF(C,1)),6,1) * 100;
DRAWTEXT(CROSS(80, RSI6), H, '★短跑'), COLORFFDDEE;
DRAWTEXT(CROSS(RSI6, 20), L, '★机会'), COLORRED;
