交易之道2024 建立自己的交易体系和风格 主副图 源码分享 附图
{引用MACD源码如下:}
DIF:=(EMA(CLOSE,4)-EMA(CLOSE,12));
DEA:=EMA(DIF,7);
MACD:=(DIF-DEA)*2;
TS:BARSLASTCOUNT(EXIST(CROSS(DIF,DEA),12) AND (DIF>0 OR CROSS(DIF,0)));
{主升MACD源码如下:}
DRAWGBK(O>C,RGB(40,40,40),RGB(0,0,10),0,'01',0);
周DB:="MACD.DIF#WEEK",COLORRED;
周AB:="MACD.DEA#WEEK",COLORRED;
月DB:="MACD.DIF#MONTH",COLOR0080FF;
月AB:="MACD.DEA#MONTH",COLOR0080FF;
NOTEXTDIF5:=EMA(CLOSE,12)-EMA(CLOSE,26);
NOTEXTDEA5:=EMA(NOTEXTDIF5,9);
NOTEXTMACD:=2*(NOTEXTDIF5-NOTEXTDEA5),COLORSTICK;
月金叉3红箭:CROSS(月DB,月AB),NODRAW,COLORMAGENTA;
DRAWGBK_DIV(月金叉3红箭,RGB(0,0,0),RGB(140,10,30),0,0);
SBL:= STRCAT(STRCAT(STRCAT(HYBLOCK,DYBLOCK),GNBLOCK),ZDBLOCK);
DRAWTEXT_FIX(1,0,0,0,SBL),COLOR0090FF;
DIF:EMA(CLOSE,12)-EMA(CLOSE,26) COLORRED;
DEA:EMA(DIF,9) COLORGREEN;
MACD:(DIF-DEA)*2,COLORSTICK;
买线1:=LLV(MA(((C+L+O+H)/4),10),5);
卖线:=HHV(MA(((C+L+O+H)/4),5),5);
倍:=(卖线+买线1)/2;
涨停价:=ZTPRICE(REF(C,1),0.1) NODRAW;
跌停价:=DTPRICE(REF(C,1),0.1) NODRAW;
注:=CROSS(C,倍) NODRAW;
试:=H>=倍 AND C<倍 AND (C>=O OR C>=REF(CLOSE,1)) NODRAW;
价:(卖线+买线1)/2 NODRAW;
涨停:=CLOSE/REF(CLOSE,1)>=1.095;
DIF4:=EMA(CLOSE,12)-EMA(CLOSE,26);DEA4:=EMA(DIF4,9);
ZTB:=C>INTPART(REF(C,1)*(1+10/100)/0.01+0.5)*0.01-0.006 AND C=H;
启动版:=DIF4>-0.2 AND DIF4<0.35 AND
ZTB AND REF(ZTB,1)<1
AND COUNT(DIF>=-0.01,5)=5;
启动版1:=DIF4>-0.25 AND DIF4<0.25 AND ZTB AND REF(ZTB,1)<1 AND COUNT(DIF>=-0.01 OR DIF<=0.01,5)=5;
DRAWICON(启动版1,0,1);
{MACD量王线}
总量:=AMOUNT,VOLSTICK;
量比:=V/REF(MA(V,5),1),COLORBROWN,NODRAW;
几倍:=1.9;
倍量:=总量 >=REF(总量,1)*几倍 AND (IF(C<O,C>REF(C,1),1)),COLORYELLOW,NODRAW;
天量:=总量=HHV(总量,120), COLORRED;
量王:=天量&&倍量&&量比>2&&(BARSCOUNT(C)+1)>120,COLORGREEN, NODRAW;
量王线:DRAWLINE(量王,MACD,REF(量王,1),REF(MACD,1),1),COLORGREEN,DOTLINE;
A111:=C>REF(C,4);
NT:=BARSLASTCOUNT(A111);
TJ11:=NT=9;
TJ13:=ISLASTBAR AND BETWEEN(NT,5,8);
AY:=(BACKSET(TJ11>0,9) OR BACKSET(TJ13>0,NT))*NT;
DRAWTEXT(AY>0,MACD*1.02,VAR2STR(AY,0)),COLORA67D3D;
DRAWTEXT(NT=9,MACD*1.02,'9'),COLORGREEN;
B1:=C<REF(C,4);
NT0:=BARSLASTCOUNT(B1);
TJ21:=NT0=9 ;
TJ23:=ISLASTBAR AND BETWEEN(NT0,5,8);
AY1:=(BACKSET(TJ21>0,9) OR BACKSET(TJ23>0,NT0))*NT0;
DRAWTEXT(AY1>0,MACD*0.98,VAR2STR(AY1,0)),COLORA67D3D ;
DRAWTEXT(NT0=9,MACD*0.98,'9'),COLORRED;
MACD120:REF(MACD/2,BARSLAST(MACD=HHV(MACD,120))),COLORA67D3D ,LINETHICK1;
MACD250:=REF(MACD/2,BARSLAST(MACD=HHV(MACD,250))),COLOR545454 ,NODRAW;
XG:=NOT(REF(MACD120,1)=MACD120);
STICKLINE(XG,0,MACD,0,0),COLORYELLOW;
STICKLINE(MACD>=MACD250,MACD250,MACD,0,0),COLORMAGENTA;
大行情:=NOT(REF(MACD120,1)=REF(MACD250,1)) AND MACD120=MACD250;
DRAWICON(大行情,0,11);
分界:=EMA(COST(85),10){,PRECISION2,LINEDOT},COLORRED;
ZTB2:=C>INTPART(REF(C,1)*(1+10/100)/0.01+0.5)*0.01-0.006 AND C=H;
启动:=DIF>-0.2 AND DIF<0.35 AND
ZTB2 AND REF(ZTB2,1)<1
AND COUNT(DIF>=-0.01,5)=5;VAB0:=13;
{梯量3}
涨幅:=(C-REF(C,1))/REF(C,1)*100;
梯量9:=EVERY(C>O,3) AND EVERY(C>REF(C,1),2) AND EVERY(V>REF(V,1),2) AND SUM(涨幅,3)<15;
梯量4:=REF(梯量9,1) AND C>=REF(C,1);
BK:=BARSLAST(CURRBARSCOUNT=CONST(BARSLAST(FILTER(梯量9,2)))+1),LINETHICK1,COLORD355BA;
BK1:=REF(BK,1);
T3:REF(H,BK),LINETHICK1,COLORD355BA,NODRAW;
FK:=BARSLAST(CURRBARSCOUNT=CONST(BARSLAST(REF(FILTER(梯量4,3),3)))+1),NODRAW;
T7:=REF(L,FK),COLORC0C0C0 ;
AA:=FILTER(梯量9,2),NODRAW;
ZT:=(C-REF(C,1))/REF(C,1)>0.092;
AB:=COUNT(梯量9=1,50 )>=1 AND (REF(C,1)<T3 OR REF(C,2)<T3 OR REF(C,3)<T3 ) AND ZT AND( CROSS(C,T3) OR C>T3) AND DIF>0 AND DEA>0 AND C>分界;
XG15:AB*0.1,COLORGREEN,LINETHICK2;
T33:=REF(H,BARSLAST(FILTER(梯量9,2)));
墨轩首板:=T33 AND 启动;
XG16:墨轩首板*0.05,COLORRED,LINETHICK2;
DIFF:=( EMA(CLOSE,12) - EMA(CLOSE,26));
日金叉:=IF(CROSS(DIF,DEA),1,0);
日零轴上:=IF(DEA>0,1,0);
日MACD买点:=(日金叉*日零轴上)>0;
A:="MACD.DIF#WEEK";
B:="MACD.DEA#WEEK";
周金叉:=IF(CROSS(A,B),1,0);
周零轴上:=IF(B>0,1,0);
周MACD买点:=(周金叉*周零轴上)>0,COLORYELLOW,LINETHICK2;
DRAWTEXT(周MACD买点,0,'金'),COLORGREEN;
股东占流通比:=FINVALUE(244)/FINVALUE(239),NODRAW;{十大流通股东/流通}
历史衰退系数:1/(1-股东占流通比),NODRAW;
NE:=IF(FINANCE(3)=3 OR FINANCE(3)=4,0.2,0.1);
ZT5:=C+0.01>=ZTPRICE(REF(C,1),NE) AND C=H;
BS:=BARSLASTCOUNT(ZT5);
MTS:=引用MACD.TS#MONTH;
WTS:=引用MACD.TS#WEEK;
ZF:=(C/REF(C,1)-1)*100;
周金叉达标:=FILTER(WTS>=1 AND BS<=3 AND ZF>9,5);
月金叉达标:=FILTER(MTS>=1 AND BS<=3 AND ZF>9,5);
DRAWICON(月金叉达标,0,23);
DRAWICON(周金叉达标,0.1,41);
未来函数检测结果如下:
该公式包含未来函数:BACKSET
该公式包含未来函数:COST
该公式包含未来函数:FINANCE
该公式包含未来函数:#MONTH
该公式包含未来函数:#WEEK
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
{引用MACD源码如下:}
DIF赋值:(收盘价的4日指数移动平均-收盘价的12日指数移动平均)
DEA赋值:DIF的7日指数移动平均
MACD赋值:(DIF-DEA)*2
输出TS:BARSLASTCOUNT(最近12日存在DIF上穿DEA AND (DIF>0 OR DIF上穿0))
{主升MACD源码如下:}
DRAWGBK(O>C,RGB(40,40,40),RGB(0,0,10),0,'01',0)
周DB赋值:"MACD.DIF#WEEK",画红色
周AB赋值:"MACD.DEA#WEEK",画红色
月DB赋值:"MACD.DIF#MONTH",COLOR0080FF
月AB赋值:"MACD.DEA#MONTH",COLOR0080FF
NOTEXTDIF5赋值:收盘价的12日指数移动平均-收盘价的26日指数移动平均
NOTEXTDEA5:=NOTEXTDIF5的9日指数移动平均
NOTEXTMACD赋值:2*(NOTEXTDIF5-NOTEXTDEA5),COLORSTICK
输出月金叉3红箭:月DB上穿月AB,NODRAW,COLORMAGENTA
DRAWGBK_DIV(月金叉3红箭,RGB(0,0,0),RGB(140,10,30),0,0)
SBL赋值: STRCAT(STRCAT(STRCAT(HYBLOCK,DYBLOCK),GNBLOCK),ZDBLOCK)
当满足条件1时,在横轴0纵轴0位置书写文字
输出DIF:收盘价的12日指数移动平均-收盘价的26日指数移动平均 画红色
输出DEA:DIF的9日指数移动平均 画绿色
输出MACD:(DIF-DEA)*2,COLORSTICK
买线1赋值:LLV(MA(((C+L+O+H)/4),10),5)
卖线赋值:HHV(MA(((C+L+O+H)/4),5),5)
倍赋值:(卖线+买线1)/2
涨停价赋值:ZTPRICE(1日前的C,0.1) NODRAW
跌停价赋值:DTPRICE(1日前的C,0.1) NODRAW
注赋值:C上穿倍 NODRAW
试赋值:H>=倍 AND C<倍 AND (C>=O OR C>=1日前的收盘价) NODRAW
输出价:(卖线+买线1)/2 NODRAW
涨停赋值:收盘价/1日前的收盘价>=1.095
DIF4:=收盘价的12日指数移动平均-收盘价的26日指数移动平均
DEA4:=DIF4的9日指数移动平均
ZTB赋值:C>INTPART(1日前的C*(1+10/100)/0.01+0.5)*0.01-0.006 AND C=H
启动版赋值:DIF4>-0.2 AND DIF4<0.35 AND
ZTB AND 1日前的ZTB<1
AND 统计5日满足DIF>=-0.01的天数=5
启动版1:=DIF4>-0.25 AND DIF4<0.25 AND ZTB AND 1日前的ZTB<1 AND 统计5日满足DIF>=-0.01 OR DIF<=0.01的天数=5
当满足条件启动版1时,在0和1之间画图标
{MACD量王线}
总量:=AMOUNT,成交量STICK
量比赋值:V/REF(V的5日简单移动平均,1),COLORBROWN,NODRAW
几倍赋值:1.9
倍量:=总量 >=1日前的总量*几倍 AND (IF(C1日前的C,1)),画黄色,NODRAW
天量赋值:总量=120日内总量最高值, 画红色
量王赋值:天量&&倍量&&量比>2&&(C的有效数据周期数+1)>120,画绿色, NODRAW
量王线:DRAWLINE(量王,MACD,1日前的量王,1日前的MACD,1),画绿色,DOTLINE
A111赋值:C>4日前的C
NT赋值:BARSLASTCOUNT(A111)
TJ11赋值:NT=9
TJ13赋值:ISLASTBAR AND BETWEEN(NT,5,8)
AY赋值:(BACKSET(TJ11>0,9) OR BACKSET(TJ13>0,NT))*NT
DRAWTEXT(AY>0,MACD*1.02,VAR2STR(AY,0)),COLORA67D3D
当满足条件NT=9时,在MACD*1.02和'9'位置书写文字
B1赋值:C<4日前的C
NT0:=BARSLASTCOUNT(B1)
TJ21赋值:NT0=9
TJ23赋值:ISLASTBAR AND BETWEEN(NT0,5,8)
AY1:=(BACKSET(TJ21>0,9) OR BACKSET(TJ23>0,NT0))*NT0
DRAWTEXT(AY1>0,MACD*0.98,VAR2STR(AY1,0)),COLORA67D3D
当满足条件NT0=9时,在MACD*0.98和'9'位置书写文字
MACD120:REF(MACD/2,上次MACD=120日内MACD最高值距今天数),COLORA67D3D ,LINETHICK1
MACD250:=REF(MACD/2,上次MACD=250日内MACD最高值距今天数),COLOR545454 ,NODRAW
XG赋值:NOT(1日前的MACD120=MACD120)
当满足条件XG时,在0和MACD之间画柱状线
当满足条件MACD>=MACD250时,在MACD250和MACD之间画柱状线
大行情赋值:NOT(1日前的MACD120=1日前的MACD250) AND MACD120=MACD250
当满足条件大行情时,在0和11之间画图标
分界赋值:EMA(获利盘为85%的成本分布,10){,PRECISION2,LINEDOT},画红色
ZTB2:=C>INTPART(1日前的C*(1+10/100)/0.01+0.5)*0.01-0.006 AND C=H
启动赋值:DIF>-0.2 AND DIF<0.35 AND
ZTB2 AND 1日前的ZTB2<1
AND 统计5日满足DIF>=-0.01的天数=5
VAB0赋值:13
{梯量3}
涨幅赋值:(C-1日前的C)/1日前的C*100
梯量9赋值:C>O最近3日一直存在 AND EVERY(C>1日前的C,2) AND EVERY(V>1日前的V,2) AND 3的涨幅日累和<15
梯量4赋值:1日前的梯量9 AND C>=1日前的C
BK赋值:上次CURRBARSCOUNT=CONST(BARSLAST(梯量9的2过滤距今天数)+1),LINETHICK1,COLORD355BA
BK1:=1日前的BK
输出T3:BK日前的H,LINETHICK1,COLORD355BA,NODRAW
FK赋值:上次CURRBARSCOUNT=CONST(BARSLAST(3日前的梯量4的3过滤距今天数)+1),NODRAW
T7赋值:FK日前的L,COLORC0C0C0
AA赋值:梯量9的2过滤,NODRAW
ZT赋值:(C-1日前的C)/1日前的C>0.092
AB赋值:统计50 日满足梯量9=1的天数>=1 AND (1日前的CT3) AND DIF>0 AND DEA>0 AND C>分界
XG15:AB*0.1,画绿色,LINETHICK2
T33:=REF(H,上次梯量9的2过滤距今天数)
墨轩首板赋值:T33 AND 启动
XG16:墨轩首板*0.05,画红色,LINETHICK2
DIFF:=( 收盘价的12日指数移动平均 - 收盘价的26日指数移动平均)
日金叉赋值:IF(DIF上穿DEA,1,0)
如果DEA>0返回1否则返回0
日MACD买点:=(日金叉*日零轴上)>0
A赋值:"MACD.DIF#WEEK"
B赋值:"MACD.DEA#WEEK"
周金叉赋值:IF(A上穿B,1,0)
如果B>0返回1否则返回0
周MACD买点:=(周金叉*周零轴上)>0,画黄色,LINETHICK2
当满足条件周MACD买点时,在0和'金'位置书写文字
股东占流通比赋值:FINVALUE(244)/FINVALUE(239),NODRAW
输出{十大流通股东/流通}
历史衰退系数:1/(1-股东占流通比),NODRAW
NE赋值:IF(FINANCE(3)=3 OR FINANCE(3)=4,0.2,0.1)
ZT5:=C+0.01>=ZTPRICE(1日前的C,NE) AND C=H
BS:=BARSLASTCOUNT(ZT5)
MTS赋值:引用MACD.TS#MONTH
WTS赋值:引用MACD.TS#WEEK
ZF赋值:(C/1日前的C-1)*100
周金叉达标:=WTS>=1 AND BS<=3 AND ZF>9的5过滤
月金叉达标赋值:MTS>=1 AND BS<=3 AND ZF>9的5过滤
当满足条件月金叉达标时,在0和23之间画图标
当满足条件周金叉达标时,在0.1和41之间画图标