对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 (三)、副图标注的完整代码: 代码流程 DIF:EMA(CLOSE,SHORT)-EMA(CLOSE,LONG),COLORWHITE,LINETHICK2; DEA:EMA(DIF,MID),COLORYELLOW; MACD:(DIF-DEA)*2,STICK; DRAWBAND(DEA,RGB(169,169,169),DIF,RGB(153,53,204)); NOTEXT1:IF(DIF<DEA,DIF,DRAWNULL),COLORGREEN,LINETHICK2; NOTEXT2:IF(DIF>=DEA,DIF,DRAWNULL),COLORRED,LINETHICK2; NOTEXT3:DEA,COLORYELLOW,LINETHICK2; 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; GS2:=BARSLASTCOUNT(MACD>REF(MACD,1) AND MACD>0); DRAWNUMBER(MACD>REF(MACD,1) AND MACD>0,MACD*1.08,GS2),COLORMAGENTA; 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; GS4:=BARSLASTCOUNT(MACD<=REF(MACD,1) AND MACD<0); DRAWNUMBER(MACD<=REF(MACD,1) AND MACD<0,MACD,GS4),COLORGREEN; (四)、效果示意图: 效果示意图 |
|