编写MACD指标

03-08 19:49发布

老师好:对常规参数MACD进行编写: 在金叉状态中的最大DIFF的数值标注在DIFF线的上方且在当根的MACD的柱子上标注向上箭头图标; 在死叉状态中的最小DIFF的数值标注在DIFF线的下方且在...

老师好:对常规参数MACD进行编写:
在金叉状态中的最大DIFF的数值标注在DIFF线的上方且在当根的MACD的柱子上标注向上箭头图标;
在死叉状态中的最小DIFF的数值标注在DIFF线的下方且在当根的MACD的柱子上标注向下箭头图标;
付费偷看设置
发送
9条回答
文华解答
2楼-- · 03-08 20:53
参考:

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
N:=BARSLAST(CROSS(DIFF,DEA))+1;
M:=BARSLAST(CROSSDOWN(DIFF,DEA))+1;
A:=BACKSET(M=1,HHVBARS(DIFF,N)+1);
DRAWICON(CROSS(A,0.5),MACD,4);
DRAWNUMBER1(CROSS(A,0.5),DIFF,DIFF,2),COLORRED;
B:=BACKSET(N=1,LLVBARS(DIFF,M)+1);
DRAWICON(CROSS(B,0.5),MACD,5),VALIGN0;
DRAWNUMBER1(CROSS(B,0.5),DIFF,DIFF,2),VALIGN0,COLORGREEN;
不悔用文华
3楼-- · 03-08 21:13
老师好:图标都在O轴上标注:红色箭头标下,绿色标上。
文华解答
4楼-- · 03-08 21:33
DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
N:=BARSLAST(CROSS(DIFF,DEA))+1;
M:=BARSLAST(CROSSDOWN(DIFF,DEA))+1;
A:=BACKSET(M=1,HHVBARS(DIFF,N)+1);
DRAWICON(CROSS(A,0.5),0,4),VALIGN0;
DRAWNUMBER1(CROSS(A,0.5),DIFF,DIFF,2),COLORRED;
B:=BACKSET(N=1,LLVBARS(DIFF,M)+1);
DRAWICON(CROSS(B,0.5),0,5);
DRAWNUMBER1(CROSS(B,0.5),DIFF,DIFF,2),VALIGN0,COLORGREEN;
不悔用文华
5楼-- · 03-08 21:52
老师好:DIFF数值为红色时,如果后者小于前者,且价格大于前者所对应的价格时,在MACD死叉的位置上标注“顶背离”;
DIFF数值为绿色时,如果后者大于前者,且价格小于前者所对应的价格时,在MACD金叉的位置上标注“底背离”;
请参考://JC:=CROSS(DIFF,DEA);
//SC:=CROSSDOWN(DIFF,DEA);
//N1:=BARSLAST(JC)+1;
//N2:=BARSLAST(SC)+1;
HH:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(H,N1));//上次MACD红柱期间合约最大值
HH2:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(HH,1));//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(MACD,N1));//上次MACD红柱期间MACD最大值
MHD2:=VALUEWHEN(CROSSDOWN(DIFF,DEA),REF(MHD,1));//上上次MACD红柱期间MACD最大值
LL:=VALUEWHEN(CROSS(DIFF,DEA),LLV(L,N2));//上次MACD绿柱期间合约最小值
LL2:=VALUEWHEN(CROSS(DIFF,DEA),REF(LL,1));//上上次MACD绿柱期间合约最小值
MLD:=VALUEWHEN(CROSS(DIFF,DEA),LLV(MACD,N2));//上次MACD绿柱期间MACD最小值
MLD2:=VALUEWHEN(CROSS(DIFF,DEA),REF(MLD,1));//上上次MACD绿柱期间MACD最小值
A:=CROSSDOWN(DIFF,DEA)&&HH>HH2&&MHD
B:=CROSS(DIFF,DEA)&&LLMLD2;//底背离
文华解答
6楼-- · 03-08 22:13
参考:

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
N:=BARSLAST(CROSS(DIFF,DEA))+1;
M:=BARSLAST(CROSSDOWN(DIFF,DEA))+1;
A:=BACKSET(M=1,HHVBARS(DIFF,N)+1);
DRAWICON(CROSS(A,0.5),0,4),VALIGN0;
DRAWNUMBER1(CROSS(A,0.5),DIFF,DIFF,2),COLORRED;
B:=BACKSET(N=1,LLVBARS(DIFF,M)+1);
DRAWICON(CROSS(B,0.5),0,5);
DRAWNUMBER1(CROSS(B,0.5),DIFF,DIFF,2),VALIGN0,COLORGREEN;

MHD:=VALUEWHEN(M=1,HHV(DIFF,N));
MHD2:=VALUEWHEN(M=1,REF(MHD,1));
MLD:=VALUEWHEN(N=1,LLV(DIFF,M));
MLD2:=VALUEWHEN(N=1,REF(MLD,1));
A1:=MHDREF(REF(C,HHVBARS(DIFF,N)),N);//顶背离
B1:=MLD>MLD2&&N=1&&REF(C,LLVBARS(DIFF,M))
DRAWTEXT(A1,DEA,'顶背离');
DRAWTEXT(B1,DEA,'底背离'),VALIGN0;
不悔用文华
7楼-- · 03-08 22:32
老师好:价格对比不正确?