通达信回马枪主图指标公式源码
发布日期: 2025-08-13 | 阅读量:35
DRAWTEXT_FIX(1,0.02,0,0,'概念板块:')COLOR00FFFF;
DRAWTEXT_FIX(1,0.10,0,0,GNBLOCK)COLOR00FFFF;
{ 加权均价与通道 }
加权价:=(2*C+H+L)/4;
AA:=MA(加权价,5);
通道上:=AA*1.02;
通道下:=AA*0.98;
{ 动态均线通道(DMA) }
波动率:=ABS(加权价-MA(C,20))/MA(C,20);
动态均线:=DMA(C,波动率);
DMA上轨:=(1+0.07)*动态均线;
DMA下轨:=(1-0.07)*动态均线;
{ EMA多空带 }
E5:=EMA(C,5);
E13:=EMA(C,13);
DRAWBAND(E5,RGB(200,0,0),E13,RGB(0,200,0));
{ 重绘K线 }
DRAWKLINE(H,O,L,C);
{ 不同板块涨跌停幅度判断 }
ZTB:=IF(INBLOCK('科创板'),1.2,
IF(INBLOCK('创业板') AND DATE>1200823,1.2,
IF(INBLOCK('ST板块'),1.05,1.095)));
DTB:=IF(INBLOCK('科创板'),0.8,
IF(INBLOCK('创业板') AND DATE>1200823,0.8,
IF(INBLOCK('ST板块'),0.95,0.9)));
{ 涨停识别 }
涨停线:=REF(C,1)*ZTB;
涨停确认:=C>=涨停线 AND C=H AND (C-涨停线)*100/C < 0.49;
STICKLINE(涨停确认,H,L,0,1),COLORMAGENTA;
STICKLINE(涨停确认,C,O,3.2,0),COLORMAGENTA;
STICKLINE(涨停确认,C,O,2.8,0),COLOR990099;
STICKLINE(涨停确认,C,O,2.0,0),COLORBB00BB;
STICKLINE(涨停确认,C,O,1.0,0),COLORDD00DD;
STICKLINE(涨停确认,C,O,0.3,0),COLORMAGENTA;
{ 跌停识别 }
跌停线:=REF(C,1)*DTB;
跌停确认:=C<=跌停线 AND C=L AND (跌停线-C)*100/C < 0.51;
STICKLINE(跌停确认,H,L,0,1), COLOR00FF00;
STICKLINE(跌停确认,C,O,2.8,0),COLOR00AA00;
STICKLINE(跌停确认,C,O,2,0),COLOR00BB00;
STICKLINE(跌停确认,C,O,1,0),COLOR00DD00;
STICKLINE(跌停确认,C,O,0.3,0),COLOR3FFB00;
{ BBI多空线 }
M1:=5; M2:=30; M3:=60; M4:=120;
BBI:(MA(C,M1)+MA(C,M2)+MA(C,M3)+MA(C,M4))/4, COLORRED;
上升趋势:IF(BBI>REF(BBI,1),BBI,DRAWNULL),COLORRED;
走平阶段:IF(BBI=REF(BBI,1),BBI,DRAWNULL),COLORRED;
下降趋势:IF(BBI<REF(BBI,1),BBI,DRAWNULL),COLORGREEN;
{ 1. 历史涨停标记 }
历史涨停:=C/REF(C,1)>1.092 AND C/REF(C,1)<1.10095;
涨停位置:=BARSLAST(REF(历史涨停,1))+1;
涨停价:=REF(C,涨停位置);
{ 2. 回踩结构 }
回踩中枢价:=REF(L,涨停位置); { 实际是涨停当日最低价 }
回踩下沿:=涨停价*0.94;
{ 3. 回调深度 }
大幅回调:=REF(SUM((C-REF(C,1))/C*100,3)<-5,1) OR REF(SUM((C-REF(C,1))/C*100,2)<-5,1);
三阴调整:=REF(C<O,1) AND REF(C<O,2) AND REF(C<O,3);
双阴或单阳:=REF(C<O,1) OR REF(C<O,2) OR REF(C>O,1);
{ 4. 价格位置 }
价低于中枢:=REF(C,1)<涨停价 AND REF(L,2)<涨停价 AND REF(L,3)<涨停价;
价高于下沿:=REF(C,1)>回踩下沿 AND REF(C,2)>回踩下沿 AND REF(C,3)>回踩下沿;
{ 5. 时间窗口 }
近期涨停:=REF(历史涨停,4) OR REF(历史涨停,5) OR REF(历史涨停,6) OR REF(历史涨停,7) OR REF(历史涨停,8) OR REF(历史涨停,9);
{ 6. 多周期涨幅约束 }
涨势温和:=REF(C,5)/REF(C,7)<1.18 AND REF(C,5)/REF(C,25)<1.25;
涨势合理2:=REF(C,2)/REF(C,4)<1.2 AND REF(C,2)/REF(C,5)<1.3 AND REF(C,2)/REF(C,28)<1.4;
涨势合理3:=REF(C,3)/REF(C,5)<1.2 AND REF(C,2)/REF(C,6)<1.3 AND REF(C,3)/REF(C,27)<1.4;
涨势合理4:=REF(C,4)/REF(C,6)<1.2 AND REF(C,2)/REF(C,7)<1.3 AND REF(C,4)/REF(C,26)<1.4;
涨势合理5:=REF(C,5)/REF(C,7)<1.2 AND REF(C,2)/REF(C,8)<1.3 AND REF(C,5)/REF(C,25)<1.4;
涨势合理6:=REF(C,6)/REF(C,8)<1.2 AND REF(C,2)/REF(C,9)<1.3 AND REF(C,2)/REF(C,24)<1.4;
{ 7. 组合模式 }
模式A:=REF(历史涨停,4) AND 价低于中枢 AND 价高于下沿 AND 涨势温和 AND C/REF(C,1)>1.015;
模式B:=REF(历史涨停,5) AND 价低于中枢 AND REF(C,1)<REF(C,2)*0.96 AND C/REF(C,1)>1.03 AND 价高于下沿;
模式C:=REF(历史涨停,5) AND REF(C<O,2) AND REF(C<O,3) AND REF(C<O,4) AND REF(O,1)<REF(C,2) AND (REF(O,1)<REF(L,2)*0.98 OR REF(O,2)<REF(L,3)) AND C/REF(C,1)>1.015;
模式D:=REF(历史涨停,6) AND 价低于中枢 AND 价高于下沿 AND REF(SUM((C-REF(C,1))/C*100,2)<-2.5,1) AND C/REF(C,1)>1.028;
模式E:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,3)<-15,1) AND REF(C,1)<REF(C,2)*0.95 AND O<REF(L,1) AND C/O>1.03;
模式F:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,2)<-11,1) AND REF(C,1)<REF(C,2)*0.96 AND C/O>1.03;
模式G:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,3)<-12,1) AND REF(SUM((C-REF(C,1))/C*100,2)<-10,1) AND REF(O,1)<REF(L,2)*0.98 AND REF(C>O,1) AND C/O>1.02;
回马枪候选:=模式A OR 模式B OR 模式C OR 模式D OR 模式E OR 模式F OR 模式G;
回马枪信号:=FILTER(回马枪候选,1) AND NOT(L=C); { 排除一字跌停 }
{ 画K线 }
STICKLINE(回马枪信号,H,L,0,1),COLORMAGENTA;
STICKLINE(回马枪信号,C,O,2.0,0),COLORYELLOW;
{ 文字与图标 }
DRAWTEXT(回马枪信号,L*0.99,'★回马枪★'),COLORYELLOW;
DRAWICON(回马枪信号,L,9);
DRAWTEXT_FIX(1,0.10,0,0,GNBLOCK)COLOR00FFFF;
{ 加权均价与通道 }
加权价:=(2*C+H+L)/4;
AA:=MA(加权价,5);
通道上:=AA*1.02;
通道下:=AA*0.98;
{ 动态均线通道(DMA) }
波动率:=ABS(加权价-MA(C,20))/MA(C,20);
动态均线:=DMA(C,波动率);
DMA上轨:=(1+0.07)*动态均线;
DMA下轨:=(1-0.07)*动态均线;
{ EMA多空带 }
E5:=EMA(C,5);
E13:=EMA(C,13);
DRAWBAND(E5,RGB(200,0,0),E13,RGB(0,200,0));
{ 重绘K线 }
DRAWKLINE(H,O,L,C);
{ 不同板块涨跌停幅度判断 }
ZTB:=IF(INBLOCK('科创板'),1.2,
IF(INBLOCK('创业板') AND DATE>1200823,1.2,
IF(INBLOCK('ST板块'),1.05,1.095)));
DTB:=IF(INBLOCK('科创板'),0.8,
IF(INBLOCK('创业板') AND DATE>1200823,0.8,
IF(INBLOCK('ST板块'),0.95,0.9)));
{ 涨停识别 }
涨停线:=REF(C,1)*ZTB;
涨停确认:=C>=涨停线 AND C=H AND (C-涨停线)*100/C < 0.49;
STICKLINE(涨停确认,H,L,0,1),COLORMAGENTA;
STICKLINE(涨停确认,C,O,3.2,0),COLORMAGENTA;
STICKLINE(涨停确认,C,O,2.8,0),COLOR990099;
STICKLINE(涨停确认,C,O,2.0,0),COLORBB00BB;
STICKLINE(涨停确认,C,O,1.0,0),COLORDD00DD;
STICKLINE(涨停确认,C,O,0.3,0),COLORMAGENTA;
{ 跌停识别 }
跌停线:=REF(C,1)*DTB;
跌停确认:=C<=跌停线 AND C=L AND (跌停线-C)*100/C < 0.51;
STICKLINE(跌停确认,H,L,0,1), COLOR00FF00;
STICKLINE(跌停确认,C,O,2.8,0),COLOR00AA00;
STICKLINE(跌停确认,C,O,2,0),COLOR00BB00;
STICKLINE(跌停确认,C,O,1,0),COLOR00DD00;
STICKLINE(跌停确认,C,O,0.3,0),COLOR3FFB00;
{ BBI多空线 }
M1:=5; M2:=30; M3:=60; M4:=120;
BBI:(MA(C,M1)+MA(C,M2)+MA(C,M3)+MA(C,M4))/4, COLORRED;
上升趋势:IF(BBI>REF(BBI,1),BBI,DRAWNULL),COLORRED;
走平阶段:IF(BBI=REF(BBI,1),BBI,DRAWNULL),COLORRED;
下降趋势:IF(BBI<REF(BBI,1),BBI,DRAWNULL),COLORGREEN;
{ 1. 历史涨停标记 }
历史涨停:=C/REF(C,1)>1.092 AND C/REF(C,1)<1.10095;
涨停位置:=BARSLAST(REF(历史涨停,1))+1;
涨停价:=REF(C,涨停位置);
{ 2. 回踩结构 }
回踩中枢价:=REF(L,涨停位置); { 实际是涨停当日最低价 }
回踩下沿:=涨停价*0.94;
{ 3. 回调深度 }
大幅回调:=REF(SUM((C-REF(C,1))/C*100,3)<-5,1) OR REF(SUM((C-REF(C,1))/C*100,2)<-5,1);
三阴调整:=REF(C<O,1) AND REF(C<O,2) AND REF(C<O,3);
双阴或单阳:=REF(C<O,1) OR REF(C<O,2) OR REF(C>O,1);
{ 4. 价格位置 }
价低于中枢:=REF(C,1)<涨停价 AND REF(L,2)<涨停价 AND REF(L,3)<涨停价;
价高于下沿:=REF(C,1)>回踩下沿 AND REF(C,2)>回踩下沿 AND REF(C,3)>回踩下沿;
{ 5. 时间窗口 }
近期涨停:=REF(历史涨停,4) OR REF(历史涨停,5) OR REF(历史涨停,6) OR REF(历史涨停,7) OR REF(历史涨停,8) OR REF(历史涨停,9);
{ 6. 多周期涨幅约束 }
涨势温和:=REF(C,5)/REF(C,7)<1.18 AND REF(C,5)/REF(C,25)<1.25;
涨势合理2:=REF(C,2)/REF(C,4)<1.2 AND REF(C,2)/REF(C,5)<1.3 AND REF(C,2)/REF(C,28)<1.4;
涨势合理3:=REF(C,3)/REF(C,5)<1.2 AND REF(C,2)/REF(C,6)<1.3 AND REF(C,3)/REF(C,27)<1.4;
涨势合理4:=REF(C,4)/REF(C,6)<1.2 AND REF(C,2)/REF(C,7)<1.3 AND REF(C,4)/REF(C,26)<1.4;
涨势合理5:=REF(C,5)/REF(C,7)<1.2 AND REF(C,2)/REF(C,8)<1.3 AND REF(C,5)/REF(C,25)<1.4;
涨势合理6:=REF(C,6)/REF(C,8)<1.2 AND REF(C,2)/REF(C,9)<1.3 AND REF(C,2)/REF(C,24)<1.4;
{ 7. 组合模式 }
模式A:=REF(历史涨停,4) AND 价低于中枢 AND 价高于下沿 AND 涨势温和 AND C/REF(C,1)>1.015;
模式B:=REF(历史涨停,5) AND 价低于中枢 AND REF(C,1)<REF(C,2)*0.96 AND C/REF(C,1)>1.03 AND 价高于下沿;
模式C:=REF(历史涨停,5) AND REF(C<O,2) AND REF(C<O,3) AND REF(C<O,4) AND REF(O,1)<REF(C,2) AND (REF(O,1)<REF(L,2)*0.98 OR REF(O,2)<REF(L,3)) AND C/REF(C,1)>1.015;
模式D:=REF(历史涨停,6) AND 价低于中枢 AND 价高于下沿 AND REF(SUM((C-REF(C,1))/C*100,2)<-2.5,1) AND C/REF(C,1)>1.028;
模式E:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,3)<-15,1) AND REF(C,1)<REF(C,2)*0.95 AND O<REF(L,1) AND C/O>1.03;
模式F:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,2)<-11,1) AND REF(C,1)<REF(C,2)*0.96 AND C/O>1.03;
模式G:=REF(历史涨停,4) AND REF(SUM((C-REF(C,1))/C*100,3)<-12,1) AND REF(SUM((C-REF(C,1))/C*100,2)<-10,1) AND REF(O,1)<REF(L,2)*0.98 AND REF(C>O,1) AND C/O>1.02;
回马枪候选:=模式A OR 模式B OR 模式C OR 模式D OR 模式E OR 模式F OR 模式G;
回马枪信号:=FILTER(回马枪候选,1) AND NOT(L=C); { 排除一字跌停 }
{ 画K线 }
STICKLINE(回马枪信号,H,L,0,1),COLORMAGENTA;
STICKLINE(回马枪信号,C,O,2.0,0),COLORYELLOW;
{ 文字与图标 }
DRAWTEXT(回马枪信号,L*0.99,'★回马枪★'),COLORYELLOW;
DRAWICON(回马枪信号,L,9);
