可以通过调整参数来调整macd的周期,参数的R,参数为1是大周期,参数为2是正常周期macd。
可以通过调整参数来调整macd的周期,参数的R,参数为1是大周期,参数为2是正常周期macd。
看到那个蓝色图标和红色图标。
公式是划线公式,使用未来函数,非喜勿扰,绕道即可。
MACD面积 源码是:
{参数R默认2}
DIFF:EMA(CLOSE,12*R)-EMA(CLOSE,26*R);
DEA:EMA(DIFF,9*R);
MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2;
红面积:=IF(MACD>0,SUM(MACD,BARSLAST(MACD<0)),0),NODRAW,COLORRED;
绿面积:=ABS(IF(MACD<0,SUM(MACD,BARSLAST(MACD>0)),0)),NODRAW,COLORLIGREEN;
AA:=ROUND(绿面积*100);
BB:=ROUND(红面积*100);
T1:=BARSLAST(CROSS(MACD>0,0.5));
红柱最高:=FILTERX(HHV(MACD,T1+1)=MACD,T1);
STICKLINE(红柱最高,0,MACD,0.5,0),COLORRED;
T2:=BARSLAST(CROSS(MACD<0,0.5));
绿柱最低:=FILTERX(LLV(MACD,T2+1)=MACD,T2);
STICKLINE(绿柱最低,0,MACD,0.5,0),COLORCYAN;
DRAWNUMBER(红柱最高,0,ABS(BB)),COLORRED;
DRAWNUMBER(绿柱最低,0,ABS(AA))DRAWABOVE,COLORGREEN;
{MACD反推值}
QN1:=12;QN2:=26; QM:=9;
QDIFF:= EMA(CLOSE,QN1*R)-EMA(CLOSE,QN2*R);
QDEA:=EMA(QDIFF,QM*R);
今日交叉价:((REF(EMA(C,QN2),1)*(QN2-1)*(QN1+1))+(REF(QDEA,1)*(QN1+1)* (QN2+1))-(REF(EMA(C,QN1),1)*(QN1-1)*(QN2+1)))/(2*(QN2-QN1))NODRAW;
明日交叉价:((EMA(C,QN2)*(QN2-1)*(QN1+1))+(QDEA*(QN1+1)*(QN2+1))-(EMA(C,QN1)*(QN1-1)*(QN2+1)))/(2*(QN2-QN1))NODRAW;
SS:=12*R;LL:=26*R;
DIFQ:=EMA(C,SS)-EMA(C,LL);
ZY1:=REF(EMA(C,SS),1);
ZY2:=REF(EMA(C,LL),1);
ZD:=REF(DIFQ,1);
JY1:=EMA(C,SS);
JY2:=EMA(C,LL);
今日DIF拐头价:(ZD*(SS+1)*(LL+1)-(SS-1)*(LL+1)*ZY1+(SS+1)*(LL-1)*ZY2)/(2*(LL-SS))NODRAW;{今日DIF拐头价}
明日DIF拐头价:(DIFQ*(SS+1)*(LL+1)-(SS-1)*(LL+1)*JY1+(SS+1)*(LL-1)*JY2)/(2*(LL-SS))NODRAW;{明日DIF拐头价}
DD:=(MACD/2+(DEA*(QM-1)/(QM+1)))/(1-2/(QM+1));{计算出明日MACD=MACD时的DIFF值}
柱子变向价:(DD*(QN1+1)*(QN2+1)-(QN2+1)*(QN1-1)*EMA(C,QN1)+(QN1+1)*(QN2-1)*EMA(C,QN2))/(2*((QN2+1)-(QN1+1)))NODRAW;{计算MACD柱体变向时的对应股价};
DIF1:=(EMA(CLOSE,12*R)-EMA(CLOSE,26*R)),COLORGREEN;
DEA1:=EMA(DIF1,9*R),COLORYELLOW;
MACD1:=2*(DIF1-DEA1),COLORSTICK;
红面积1:=SUM(MACD1,BARSLAST(MACD1<0))*1,COLOR0000FF,NODRAW;
红面积2:=SUM(MACD1,(SUMBARS(MACD1<0,2)*1-BARSLAST(MACD1<0)+1)),NODRAW;
绿面积1:=SUM(MACD1,BARSLAST(MACD1>0))*1,COLORFFFF00,NODRAW;
绿面积2:=SUM(MACD1,(SUMBARS(MACD1>0,2)*1-BARSLAST(MACD1>0)+1));
积底背:=CROSS(DIF1,DEA1) AND EVERY(DIF1<0,BARSLAST(CROSS(0,DIF1))) AND 绿面积1<绿面积2 AND DIF1>REF(DIF1,(SUMBARS(CROSS(DIF1,DEA1),2)-1));
DRAWTEXT(积底背,DIF1,'底背'),COLORMAGENTA;
积顶背:=CROSS(DEA1,DIF1) AND EVERY(DIF1>0,BARSLAST(CROSS(DIF1,0))) AND 红面积1>红面积2 AND DIF1<REF(DIF1,(SUMBARS(CROSS(DEA1,DIF1),2)-1));
DRAWTEXT(积顶背,DEA1,'顶背')DRAWABOVE,COLORYELLOW;
QT1:=BARSLAST(CROSS(MACD>0,0.5));
QT2:=BARSLAST(CROSS(MACD<0,0.5));
快线最高:=FILTERX(HHV(DIFF,QT1+1)=DIFF,QT1);
快线最低:=FILTERX(LLV(DIFF,QT2+1)=DIFF,QT2);
STICKLINE(红柱最高,0,MACD,1.2,0),COLORRED;
STICKLINE(绿柱最低,0,MACD,1.2,0),COLORYELLOW;
STICKLINE(快线最低,DIFF*0.98,DIFF*1.0002,2,0),COLORBLUE;
STICKLINE(快线最高,DIFF*0.98,DIFF*1.0002,2,0),COLORMAGENTA;
{DRAWTEXT(红柱最高,MACD,'柱最高')COLORRED,DRAWABOVE;
DRAWTEXT(快线最高,DIFF,'快线最高')COLORMAGENTA,DRAWABOVE;
DRAWTEXT(绿柱最低,MACD,'柱最低')COLORYELLOW;
DRAWTEXT(快线最低,DIFF*0.990,'快线最低')COLORBLUE;}
STICKLINE(绿柱最低,0,MACD,0.5,0),COLORCYAN;
DRAWNUMBER(红柱最高,0,ABS(BB)),COLORRED;
DRAWNUMBER(绿柱最低,0,ABS(AA))DRAWABOVE,COLORGREEN;
1824111869.png
1824244213.png
1824322305.jpg
|