龙听期货论坛's Archiver

龙听 发表于 2018-1-22 21:52

MACD红绿柱面积公式(大智慧指标)

MACD红绿柱面积公式:
[code]
DIF : 10*(EMA(CLOSE,short) - EMA(CLOSE,long));
DEA : EMA(DIF,mid);
MACD : 2*(DIF-DEA), COLORSTICK;

{面积计算}//注:SUM(MACD在N周期内的总和 BARLAST上一次条件成立(macd>0)到当前的周期数;
绿面积:IF (MACD<0,SUM(MACD,BARSLAST(MACD>0)) * 100,0),linethick0,colorgreen;
红面积:IF (MACD>0,SUM(MACD,BARSLAST(MACD<0)) * 100,0),linethick0,colorred;

DRAWTEXT( ref(MACD,1)>0 and MACD<=0 ,HHV(MACD,4), NUMTOSTRN(REF(红面积, 1), 3)), colorred,valign2;
DRAWTEXT( ref(MACD,1)<0 and MACD>=0 ,LLV(MACD,4), NUMTOSTRN(REF(绿面积, 1), 3)), colorgreen;
{当前面积}
DRAWTEXT(BARSTATUS=2 and macd>0, -macd*0.03, NUMTOSTRN(红面积, 1),3), coloryellow,valign0, align2;
DRAWTEXT(BARSTATUS=2 and macd<=0, -macd*0.03, NUMTOSTRN(绿面积, 1),3), coloryellow,valign2,align2;

{多空线: 0, colorwhite, dotline;}
stickline(MACD<0 and MACD>=REF(MACD, 1), 0, macd, 0, 0), linethick2,colorwhite;
stickline(MACD<0 and MACD
stickline(MACD>=0 and MACD>REF(MACD, 1), 0, macd, 0, 0), linethick2,colorred;
stickline(MACD>=0 and MACD<=REF(MACD, 1), 0, macd, 0, 0),linethick2, colorwhite;

{根据条件变色绘制dif线,当dif向上时画红线,dif向下时画绿线}
partline(dif,dif>=ref(dif,1),rgb(255,0,0),dif﹤ref(dif,1),rgb(0,255,0)),linethick2;
[/code]

页: [1]