对MACD柱线应用不同的颜色标示,关键在于不同限定条件的罗列,请看留言截图:
(资料图片仅供参考)
网友的留言
网友留言的思路是:建立副图算法--- 如何在0轴上下方MACD柱体最长柱体为分水岭用两种不同颜色显示出来。
(一)、思路步骤的罗列:
1.引入系统自带的指标算法;
2.限定MACD柱线的条件;
a.MACD大于0,并且柱线下降
b. MACD大于0,并且柱线上升
c. MACD小于等于0,并且柱线下降
d. MACD小于等于0,并且柱线上升
(二)、算法的建立过程:
1.引入系统算法
引入算法
2.限定MACD柱线之间的空间关系条件
a.MACD大于0,并且柱线下降
MACD <= REF ( MACD , 1 ) AND MACD >0
b. MACD大于0,并且柱线上升
MACD >REF ( MACD , 1 ) AND MACD >0
c. MACD小于等于0,并且柱线下降
MACD <= REF ( MACD , 1 ) AND MACD < 0 ,
d. MACD小于等于0,并且柱线上升
MACD >REF ( MACD , 1 ) AND MACD < 0
(三)、完整代码:
代码流程
DIFF : EMA ( CLOSE ,SHORT) - EMA ( CLOSE ,LONG);
DEA : EMA (DIFF,M);
MACD : 2 *(DIFF-DEA), COLORSTICK ;
Zero : 0 ;
STICKLINE ( MACD >REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 2.5 , 0 ), COLOR1155BB ;
STICKLINE ( MACD >REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 2 , 0 ), COLOR2266CC ;
STICKLINE ( MACD >REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 1.5 , 0 ), COLOR3377DD ;
STICKLINE ( MACD >REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 1 , 0 ), COLOR4488EE ;
STICKLINE ( MACD >REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 0.5 , 0 ), COLOR5599FF ;
STICKLINE ( MACD >0 ,- 0 , MACD , 2.5 , 0 ), COLOR400055 ;
STICKLINE ( MACD >0 ,- 0 , MACD , 2 , 0 ), COLOR400066 ;
STICKLINE ( MACD >0 ,- 0 , MACD , 1.5 , 0 ), COLOR400077 ;
STICKLINE ( MACD >0 ,- 0 , MACD , 1 , 0 ), COLOR400088 ;
STICKLINE ( MACD >0 ,- 0 , MACD , 0.5 , 0 ), COLOR400099 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD >0 ,- 0 , MACD , 2.5 , 0 ), COLOR888888 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD >0 ,- 0 , MACD , 2 , 0 ), COLOR999999 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD >0 ,- 0 , MACD , 1.5 , 0 ), COLORAAAAAA ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD >0 ,- 0 , MACD , 1 , 0 ), COLORBBBBBB ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD >0 ,- 0 , MACD , 0.5 , 0 ), COLORCCCCCC ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 2.5 , 0 ), COLOR555500 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 2 , 0 ), COLOR666600 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 1.5 , 0 ), COLOR777700 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 1 , 0 ), COLOR888800 ;
STICKLINE ( MACD <= REF ( MACD , 1 ) AND MACD < 0 ,- 0 , MACD , 0.5 , 0 ), COLOR999900 ;
(四)、效果示意图:
效果示意图