MACD柱的分色标示

对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 ;

(四)、效果示意图:

效果示意图

关键词:

推荐DIY文章
主机存在磨损或划痕风险 PICO4便携包宣布召回
穿越湖海!特斯拉Cybertruck电动皮卡可以当“船”用
vivoXFold+折叠旗舰开售 配备蔡司全焦段旗舰四摄
飞凡R7正式上市 全系标配换电架构
中兴Axon30S开售 拥有黑色蓝色两款配色
荣耀MagicBookV14 2022正式开售 搭载TOF传感器
it