#----------------------------------------------------------------------------------
#-----MACD 系统默认参数 12、26、9
DIF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
#----------------------------------------------------------------------------------
#-----MACD 放大坐标系 100倍 参数 12、26、9
DIF:EMA(CLOSE*100,12)-EMA(CLOSE*100,26);
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
#----------------------------------------------------------------------------------
#-----MACD 变色 参数 12、26、9
DIF:(EMA(CLOSE,12)-EMA(CLOSE,26))*10000;
DEA:EMA(DIF,9);
MACD:(DIF-DEA)*2,COLORSTICK;
DIF1:IF(DIF<=REF(DIF,1),DIF,DRAWNULL),COLORRED,;
DEA1:IF(DEA<=REF(DEA,1),DEA,DRAWNULL),COLORFF00FF;
#----------------------------------------------------------------------------------
#-----MACD 跨周期放大参数系数N1 参数 12、26、9
N1=6;
DIF1:=EMA(CLOSE,12*N1)-EMA(CLOSE,26*N1);
DEA1:=EMA(DIF1,9*N1);
MACD1:=(DIF1-DEA1)*2,COLORSTICK;
#----------------------------------------------------------------------------------
#-----VOL 无均线,带变色柱线
VOLUME:VOL,VOLSTICK;
#----------------------------------------------------------------------------------
#-----KDJ 跨周期放大参数系数N1 参数 12、26、9
N1:=3;
RSV:=(CLOSE-LLV(LOW,9*N1))/(HHV(HIGH,9*N1)-LLV(LOW,9*N1))*100;
K:=SMA(RSV,3*N1,1);
D:=SMA(K,3*N1,1);
J:=3*K-2*D;
N2:=18;
RSV2:=(CLOSE-LLV(LOW,9*N2))/(HHV(HIGH,9*N2)-LLV(LOW,9*N2))*100;
K2:=SMA(RSV2,3*N2,1);
D2:=SMA(K2,3*N2,1);
J2:=3*K2-2*D2;
#----------------------------------------------------------------------------------
#-----kdj 变色 参数 9、3 、3
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:SMA(RSV,3,1);
D:SMA(K,3,1);
J:3*K-2*D,COLORRED;
K1:IF(K<=REF(K,1),K,DRAWNULL),COLOR800080,LINETHICK2;
D1:IF(D<=REF(D,1),D,DRAWNULL),COLOR40FF00,LINETHICK2;
J1:IF(J<=REF(J,1),J,DRAWNULL),COLORLIBLUE,LINETHICK2;
#----------------------------------------------------------------------------------
#-----各种均线
A1:=C; N1:=120; N2:=0.3;
MA1:=MA(A1,N1); {简单移动平均}
MEMA1:MEMA(A1,N1); {平滑移动平均}
EMA1:EMA(A1,N1); {指数移动平均}
WMA1:=WMA(A1,N1); {加权移动平均}
DMA1:=DMA(A1,N2); {以N2为权重A1的动态移动平均}
AMA1:=AMA(A1,N2); {以N2为权重A1的自适应均线}
XMA1:XMA(A1,N1); {A1的N1日偏移移动平均}
#----------------------------------------------------------------------------------
#-----龙虎榜 标记
A1:=GPJYVALUE(2,1,0);
A2:=IF(A1>0 ,1,0);
A3:=COUNT(A2=1,N2);
A4:=IF(A3>=N1,1,0);
DRAWTEXT(A2,L*0.95,'榜'),COLORYELLOW;
#----------------------------------------------------------------------------------
#-----龙虎榜 各项数据
A:=SIGNALS_USER(300, 0), NODRAW; {上榜总金额}
B:=SIGNALS_USER(299, 0), NODRAW; {净流入}
D:=(A+B)/2,NODRAW;{总买入}
E:=A-D,NODRAW;{总卖出};
F:=AMO/10000,NODRAW;{当日成交金额 万元}
J:=A/F*100,NODRAW;{上榜资金与成交金额占比}
#----------------------------------------------------------------------------------
#-----跟势交易法用,数K线个数 画线
DRAWSL(ISLASTBAR=1,C,0,80,1),COLORMAGENTA;
DRAWSL(ISLASTBAR=1,C,0,60,1),COLORYELLOW;
DRAWSL(ISLASTBAR=1,C,0,40,1),COLORMAGENTA;
DRAWSL(ISLASTBAR=1,C,0,20,1),COLORYELLOW;
#----------------------------------------------------------------------------------
#-----画图 画线,标记,显示文字
DRAWICON(CC,H*1.02,2);
DRAWTEXT(CC,H*1.025,VAR2STR(H,2)),COLORMAGENTA;
DRAWNUMBER_FIX(CC,0,0,0,MA1);
#----------------------------------------------------------------------------------
#-----K线训练营 分时图
A0:= TIME=934 AND C=9.49;
A1:=REF(TIME,1)=933 AND REF(C,1)=9.51;
A2:=REF(TIME,2)=932 AND REF(C,2)=9.56;
A3:=REF(TIME,3)=931 AND REF(C,3)=9.48;
A5:=BARSLAST(A0 AND A1 AND A2 AND A3 );
A6:(A5+5)/240;
#----------------------------------------------------------------------------------
#-----K线训练营 日线
A:= O=4.47 AND H=4.51 AND L=4.41 AND REF(C,1)=4.48;
A2:BARSSINCE(A=1);
#----------------------------------------------------------------------------------
#-----首板涨停 7日内首板涨停
N:=7;
A1:=GPJYVALUE(15,2,0);
A2:=IF(A1>1,1,0);
A3:=COUNT(A2,N);
A4:A2=1 AND A3=1;
#----------------------------------------------------------------------------------
#-----涨停板 {计算方式 分板块计算}
#---上交所官方文件 原话:
#---股票、基金涨跌幅价格的计算公式为:涨跌幅价格=前收盘价×(1±涨跌幅比例)。
#---计算结果按照四舍五入原则取至价格最小变动单位。};
A1:=IF(INBLOCK('创业板') OR INBLOCK('科创板'),1,0);
A2:=IFC(A1=1,ROUND2(REF(C,1)*1.2,2),ROUND2(REF(C,1)*1.1,2));{昨日收盘价}
A3:IF(A2=C,1,0);
#----------------------------------------------------------------------------------
#-----跌停板 {计算方式 分板块计算}
B1:=IF(INBLOCK('创业板') OR INBLOCK('科创板'),1,0);
B2:=IFC(B1=1,ROUND2(REF(C,1)*0.8,2),ROUND2(REF(C,1)*0.9,2));{昨日收盘价}
B3:IF(B2=C,1,0);
{计算方式};
#----------------------------------------------------------------------------------
#-----涨停板 {调取专业财务数据涨停函数}
B1:=GPJYVALUE(15,2,0);
B2:IF(B1>1,1,0); {适合盘后用}
A4:=IF(A3<>B2,1,0); {验证计算式和调取财务数据是否一致}
A5:=COUNT(A4,300);
A6:=IF(A5>1,1,0);
#----------------------------------------------------------------------------------
#-----涨停板,连板天数
DYNAINFO(90)=1; {首板}
DYNAINFO(90)=3; {连板天数=3} DYNAINFO(90) 连板天数(对沪深京有效)
#----------------------------------------------------------------------------------
#-----用分钟周期标记涨停
A1:=IF(INBLOCK('创业板') OR INBLOCK('科创板'),1,0);
T1:=DAY<>REF(DAY,1);
T2:=BARSLAST(T1)+1;
A2:=IFC(A1=1,ROUND2(REF(C,T2)*1.2,2),ROUND2(REF(C,T2)*1.1,2));
A3:=IF(A2=C,1,0);
XG:= A3=1 AND TIME<=0940; {用在5分钟周期上, 9.40前涨停}
XG2:COUNT(A3=1 AND TIME<=0940,145)>=1 ; {用在5分钟周期上, 三日内出现9.40前涨停};
#----------------------------------------------------------------------------------
#-----涨停板 主板10%涨停 只计算主板的涨停,创科板不适用
A1:=IF(CODELIKE('68') OR CODELIKE('30') OR NAMELIKE('*ST') OR NAMELIKE('ST'),0,1);
A2:=IFC(A1=1,ROUND2(REF(C,1)*1.1, 2),0);{昨日收盘价}
A3:IF(A2=C,1,0); {只计算主板10 % 的涨停,其他板块不算}
去除:=IF(CODELIKE('68') OR CODELIKE('30') OR NAMELIKE('*ST') OR NAMELIKE('ST'),0,1);
{去除科创板,创业板,ST板};
#----------------------------------------------------------------------------------
#-----筛选去除银行ST 688,300市值等各种要求
DRAWTEXT_FIX(ISLASTBAR,0,0.00,0,STRCAT('行业:',HYBLOCK));
A1:=IF(CODELIKE('68') OR INBLOCK('银行') OR NAMELIKE('*ST') OR NAMELIKE('ST'),0,1);
IF(INBLOCK('软件服务'),1,0);
#----------------------------------------------------------------------------------
#-----板块个股涨停
A1:=BKJYVALUE(12,1,1); {涨停个数}
A2:=BKJYVALUE(13,1,1); {跌停个数}
显示涨幅10:=1;
今最:=BKJYVALUE(12,1,1);
ZFSJZH109:=STRCAT(STRCAT('【板块涨停:',VAR2STR(今最,0)),'家');
ZFSJZH209:=STRCAT(ZFSJZH109,' 板块跌停: '),COLORGREEN;
ZDDF09:=BKJYVALUE(12,2,1);
ZFSJZH309:=STRCAT(ZFSJZH209,VAR2STR(CONST(ZDDF09),0));
ZFSJZH409:=STRCAT(ZFSJZH309,'家】');
DRAWTEXT_FIX(显示涨幅10=1,0.58,0.0,0,ZFSJZH409),COLORYELLOW;
#----------------------------------------------------------------------------------
#-----盘口数据
涨幅:DYNAINFO(14)*100;
振幅:DYNAINFO(13)*100;
换手:DYNAINFO(37)*100;
内外盘:(SELLVOL-BUYVOL)/BUYVOL; (内盘-外盘)/外盘
T1:=DAY<>REF(DAY,1);
T2:=BARSLAST(T1)+1;
昨日收盘价 YD:=REF(C,T2);{昨日收盘价,日线的};
沪A涨家数:="999999$ADVANCE",COLORRED,NODRAW;
深A涨家数:="399107$ADVANCE",COLORRED,NODRAW;
上涨总家数:=沪A涨家数+深A涨家数;
上涨总家数1:沪A涨家数+深A涨家数,NODRAW;
上涨家数即时:DYNAINFO(60),NODRAW;
上涨总家数2:"880005$C",NODRAW;
涨停封板手数:DYNAINFO(59)=0 and DYNAINFO(58)<50000 58买一量 59卖一量
#----------------------------------------------------------------------------------
#-----获利筹码大于90%
A1:=PWINNER(0,C)*100;
A2:=REF(A1,1)>90;
#----------------------------------------------------------------------------------
#-----获利筹码90% 通达信写法
CM9:(COST(95)-COST(5))/COST(99.99999)*100;
CB:=DMA(((2*C+H+L)/4+(2*H+L+C)/4+(2*L+C+H)/4)/3*90,HSL/90)/90,COLORRED;
#----------------------------------------------------------------------------------
#-----获利筹码90% 飞狐写法
CM9:(COST(95)-COST(5))/(COST(95)+COST(5))*100;
#----------------------------------------------------------------------------------
#-----大单预警V1
A0:DYNAINFO(9);
A1:FINANCE(1)/100/10000;
A3:=C>MA(C,5);
XX:IF(A0>A1 AND DYNAINFO(49)=0 ,A1+100,50);
DRAWICON(A0>A1 AND DYNAINFO(49)=0,A1-200,9);
A5:DYNAINFO(49);
#----------------------------------------------------------------------------------
#-----引用指标
("MACD.DIF"(12,26,9)
A1:"999999$C",COLORRED;
A2:="999999$ZSPJ.A1",COLORRED;
A3:CALCSTOCKINDEX('999999','ZSPJ',1);
#----------------------------------------------------------------------------------
#-----引用指数
A1:"SH000016$CLOSE"; {引用上证50指数的CLOSE}
A2:"000016$CLOSE"; {引用深康佳个股的CLOSE}
A3:"SH000905$CLOSE"; {引用中证500指数的CLOSE}
A4:"999999$C"; {引用上证指数的CLOSE}
A5:CALCSTOCKINDEX('999999','ZSPJ',1); {引用上证指数的CLOSE}
被引用指标 ZSPJ A1:DYNAINFO(3);
#----------------------------------------------------------------------------------
#-----信号标记
A1:=REF(C,1)>REF(C,2) AND C<REF(C,1);{信号出现的位置}
A2:=BACKSET(A1,2);{这个BACKSET的作用是把信号往左挪一个K线}
A3:PLOYLINE(REF(A2,1)=0 AND A2=1,C);
#----------------------------------------------------------------------------------
#-----分时均线 { 官方红宝书给的 适用于1分钟,5分钟,15分钟,30分钟,60分钟等五个周期 的分时均线}
FIRST:=IF(PERIOD=0,HOUR=9 AND MINUTE=31,
IF(PERIOD=1,HOUR=9 AND MINUTE=35,
IF(PERIOD=2,HOUR=9 AND MINUTE=45,
IF(PERIOD=3,HOUR=10 AND MINUTE=0,
IF(PERIOD=4,HOUR=10 AND MINUTE=30,0)))));
SUM(AMO,BARSLAST(FIRST)+1)/SUM(VOL,BARSLAST(FIRST)+1)/100;
#----------------------------------------------------------------------------------
#-----分时均线 我写的
T1:=DAY<>REF(DAY,1);
T2:=BARSLAST(T1)+1;
JX:=SUM(AMOUNT,T2)/SUM(V,T2)/100;
#----------------------------------------------------------------------------------
#-----涨幅
ZF:=(C-REF(C,1))/REF(C,1)*100
T1:=DAY<>REF(DAY,1);
T2:=BARSLAST(T1)+1;
ZF2:=(C/REF(C,T2)-1)*100; {分钟图上当日股价涨幅}
YD:=REF(C,T2);{昨日收盘价,日线的};
#----------------------------------------------------------------------------------
#-----个股涨幅排名
{个股在全部A股的涨幅排名}
DRAWTEXT_FIX(ISLASTBAR,0,0,0,CON2STR(INSORT('全部A股','ZF01',1,0),0)),COLORYELLOW; {展示到主图左上角}
A1:=INSORT('全部A股','ZF01',1,0),NODRAW;{输出数字}
{个股在全部A股的涨幅排名3%以上个数}
DRAWTEXT_FIX(ISLASTBAR,0,0.05,0,CON2STR(INSUM('全部A股','ZF02',1,0),0)),COLORYELLOW; {展示到主图左上角}
A2:INSORT('全部A股','ZF02',1,0),NODRAW;{输出数字}
{ZF02---ZF:(C-REF(C,1))/REF(C,1)*100>3;}
{板块指数排名,需要新建自定义板块:我的指数}
A3:INSORT('我的指数','ZF01',1,0);
#----------------------------------------------------------------------------------
#-----个股涨幅排名2 在行业板块内排名 放在主图左上角
DRAWTEXT_FIX(ISLASTBAR,0,0.00,0,STRCAT('行业:',HYBLOCK)),COLORYELLOW;
DRAWTEXT_FIX(ISLASTBAR,0,0.04,0,STRCAT('概念:',GNBLOCK)),COLORYELLOW;
A1:=CALCSTOCKINDEX(HYZSCODE,'ZF01',1);
B1:=HORCALC(HYBLOCK,105,1,DRAWNULL);
DRAWTEXT_FIX(ISLASTBAR,0,0.08,0,STRCAT('涨幅:',VAR2STR(A1,2))),COLORYELLOW;
DRAWTEXT_FIX(ISLASTBAR,0,0.12,0,STRCAT('排名:',CON2STR(B1,0))),COLORYELLOW;
#----------------------------------------------------------------------------------
#-----个股涨幅排名3 个股在全部A股的涨幅排名3%以上个数}
DRAWTEXT_FIX(ISLASTBAR,0,0.05,0,CON2STR(INSUM('全部A股','ZF02',1,0),0)),COLORYELLOW; {展示到主图左上角}
A2:INSUM('全部A股','ZF02',1,0),NODRAW;{输出数字};
#----------------------------------------------------------------------------------
#-----小实体阳线 或阴线 或者大阳线 大阴线
ZF1:=(C-REF(C,1))/REF(C,1)*100;
ZF2:=(O-REF(C,1))/REF(C,1)*100;
A1:=ABS(ZF1-ZF2);
XG: A1<1.6 小实体阳线或阴线 A1>6 大阳线 大阴线
#----------------------------------------------------------------------------------
#-----缠论包含处理
STICKLINE(1,H,L,3,0);
A1:=H<REF(H,1) AND L>REF(L,1); {向后}
A2:=H>REF(H,1) AND L<REF(L,1); {向前}
#----------------------------------------------------------------------------------
#-----日内涨幅 分时图用,盘中用的
ZF1:=(C/DYNAINFO(3)-1)*100;
A1:=ZF1-REF(ZF1,1);
#----------------------------------------------------------------------------------
#-----信号标记
A1:=REF(C,1)>REF(C,2) AND C<REF(C,1);{信号出现的位置}
A2:=BACKSET(A1,2);{这个BACKSET的作用是把信号往左挪一个K线}
A3:PLOYLINE(REF(A2,1)=0 AND A2=1,C);
标签:#------------------------------------------------------------------------------- From: https://www.cnblogs.com/long136/p/16888816.html