大智慧背离面积公式
DIFF:EMA(CLOSE,10) - EMA(CLOSE,22),LINETHICK0;
DEA :EMA(DIFF,7.5),LINETHICK0;
MACD :2*(DIFF-DEA),LINETHICK0;
HZL:=CROSS(MACD,0);
LZH:=CROSS(0,MACD);
BC:=BARSLAST(HZL OR LZH)+1;
ZGHZ:=IF(MACD>0,HHV(MACD,bc),0);
ZDLZ:=IF(MACD<0,LLV(MACD,bc),0);
FILLRGN(ZDLZ,0,MACD<0,RGB(44,88,44),MACD<0,RGB(0,0,0));
FILLRGN(ZGHZ,0,MACD>0,RGB(99,55,55),MACD<0,RGB(0,0,0));
FILLRGN(DIFF,DEA,DIFF>DEA,RGB(142,66,140),DIFF<DEA,RGB(64,129,129));{
PARTLINE(CROSS(DIFF,DEA) AND DIFF<0,DIFF),CROSSDOT,LINETHICK3,COLORff00FF;
PARTLINE(CROSS(DEA ,DIFF),DIFF),CROSSDOT,LINETHICK3,COLOR00ff00;}
STICKLINE(MACD>0 AND MACD>REF(MACD,1),0,MACD,5,1),COLORRED;
STICKLINE(MACD>0 AND MACD<REF(MACD,1),0,MACD,5,0),COLOR90FF00;
STICKLINE(MACD<0 AND MACD<REF(MACD,1),0,MACD,5,1),COLOREFFF00;
STICKLINE(MACD<0 AND MACD>REF(MACD,1),0,MACD,5,0),COLORFFAAFF;
↑:TROUGHBARS(3,3,1),COLOR0000FF,LINETHICK0;
↓:PEAKBARS(3,3,1),COLOR00FF00,LINETHICK0;
低:=IF(↑=0,DIFF,IF(↓<↑,TROUGH(3,3,1),REF(TROUGH(3,3,1),1)));
高:=IF(↓=0,DIFF,IF(↑<↓,PEAK(3,3,1),REF(PEAK(3,3,1),1)));
STICKLINE(↑=0 AND DIFF<0 AND DIFF<DEA,0,DIFF,0,0),COLOR0000FF;
STICKLINE(↓=0 AND DIFF>0 AND DIFF>DEA,DIFF,0,0,0),COLOR00FF00;
DRAWTEXT(↑=0 AND DIFF<0 AND DIFF<DEA,DIFF,'低'),COLORWHITE;
DRAWTEXT(↓=0 AND DIFF>0 AND DIFF>DEA,DIFF,'高'),COLOR11FF11;
PARTLINE(DIFF,CROSS(DIFF,DEA ) AND DIFF<0,RGB(2,224,12)),CROSSDOT,LINETHICK3;
PARTLINE(DIFF,CROSS(DIFF,DEA ) AND DIFF>0,RGB(255,22,222)),CROSSDOT,LINETHICK3;
PARTLINE(DIFF,CROSS(DEA,DIFF ),RGB(255,245,12)),CIRCLEDOT,LINETHICK3;
DRAWFLAGTEXT(CROSS(DIFF,DEA ) AND DIFF<0,DIFF,'MACD<0金叉');
DRAWFLAGTEXT(CROSS(DIFF,DEA ) AND DIFF>0,DIFF,'MACD>0金叉');
DRAWFLAGTEXT(CROSS(DEA ,DIFF),DIFF,'死叉');
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);
DRAWTEXT(FILTER(B1>0,5),0,'←MACD'),COLORGREEN;
A2:=BARSLAST(REF(CROSS("KDJ.K","KDJ.D"),1));
B2:=REF(C,A2+1)>C AND REF("KDJ.K",A2+1)<"KDJ.K" AND CROSS("KDJ.K","KDJ.D");
DRAWTEXT(FILTER(B2>0,5),MACD,'←KDJ'),COLORYELLOW;
A3:=BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1));
B3:=REF(C,A3+1)>C AND REF("RSI.RSI1",A3+1)<"RSI.RSI1" AND CROSS("RSI.RSI1","RSI.RSI2");
DRAWTEXT(FILTER(B3>0,5),MACD,'←RSI'),COLORCYAN;
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);
DRAWTEXT(FILTER(D1>0,5),MACD,'←MACD'),COLORWHITE;
C2:=BARSLAST(REF(CROSS("KDJ.D","KDJ.K"),1));
D2:=REF(C,C2+1)<C AND REF("KDJ.K",C2+1)>"KDJ.K" AND CROSS("KDJ.D","KDJ.K");
DRAWTEXT(FILTER(D2>0,5),MACD,'←KDJ'),COLORWHITE;
C3:=BARSLAST(REF(CROSS("RSI.RSI2","RSI.RSI1"),1));
D3:=REF(C,C3+1)<C AND REF("RSI.RSI1",C3+1)>"RSI.RSI1" AND CROSS("RSI.RSI2","RSI.RSI1");
DRAWTEXT(FILTER(D3>0,5),MACD,'←RSI'),COLORMAGENTA;
DRAWFLAGTEXT(FILTER(B2>0,5),MACD,'KDJ金叉');
DRAWFLAGTEXT(FILTER(B3>0,5),MACD,'RSI金叉');
DRAWFLAGTEXT(FILTER(D2>0,5),MACD,'KDJ死叉');
DRAWFLAGTEXT(FILTER(D3>0,5),MACD,'RSI死叉');
{DRAWTEXTABS(2,8,'【精华8个字 买小卖小,缩头缩脚】 当股价一波比一波高时,反而红柱的堆,一堆比一堆小,证明产生了顶背离现象,应该及时卖出'+''),Color1111FF;
DRAWTEXTABS(200,22,'当股价一波比一波低时,反而绿柱的堆,一堆比一堆小,证明产生了底背离现象,应该及时买进'+''),Color11FF11;};