MACD_12-26-9_TREND BAND
Incorporating a trend band with the MACD indicator in Amibroker AFL offers traders a valuable tool for trend identification. This configuration provides a visual representation of the market trend’s strength and direction. Utilizing amibroker data feed capabilities allows traders to adjust the parameters of the trend band, optimizing its effectiveness in identifying and confirming market trends.
/ _SECTION_BEGIN("MACD_12-26-9+HIST + ADXR band"); r1 = Param( "Fast avg", 12, 2, 200, 1 ); r2 = Param( "Slow avg", 26, 2, 200, 1 ); r3 = Param( "Signal avg", 9, 2, 200, 1 ); m1= MACD(r1,r2); s1= Signal(r1,r2,r3); ////////////////////////////////////////////// HIST ////////////////////////////////////// hist=m1-s1; Colorhist=IIf(hist>Ref(hist,-1),colorYellow,colorRed); Plot( hist*2, "MACD Histogram", Colorhist, styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) ); Plot( hist*2, "MACD Histogram", Colorhist, styleNoTitle | styleNoLabel, maskHistogram ); //PlotOHLC( 0, hist*2, 0 , 0 , "hist",Colorhist, styleCloud | styleNoLabel); /////////////////////////////////////// MACD ////////////////////////////////////////////////////////////////// Colorm=IIf(m1>Ref(m1,-1),colorGreen,colorDarkRed); //Plot( m1, "MACD12269", Colorm, styleHistogram ); Plot( m1, "MACD", colorCustom12, styleNoLabel|styleThick ); Plot( s1, "Signal", colorTeal, styleNoLabel|styleThick); //PlotOHLC( 0, m1, 0 , 0 , "MACD",Colorm, styleCloud | styleNoLabel); //////////////////////////////////////////// ADXR BAND ////////////////////////////////////////////////////// pds=14; Adxr = ( ADX(pds) + Ref( ADX(pds), -14 ) )/2; //Plot(ADxr,"",colorWhite,4); //Plot( PDI(14), "+DI",ColorRGB(0,100,20),styleThick | styleNoLabel); //Plot( MDI(14), "-DI",ColorRGB(100,0,20),styleThick | styleNoLabel); A = PDI(14); B = MDI(14); //PlotOHLC( 0, A , B , B , "Cloud", IIf(A > B ,ColorRGB(0,25,10),ColorRGB(35,0,10)), styleCloud | styleNoLabel); ColorA=IIf(ADXr>25,IIf(A>B,IIf(ADXr>EMA(ADXr,3),colorBrightGreen,colorGreen),IIf(ADXr>EMA(ADXr,3),colorRed,colorDarkRed)),colorBlack); Plot( 3,"",ColorA, /* choose color */styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); Plot( 4,"",colorBlack, /* choose color */styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); ////////////////////////////////////////////////// MACD TRENDING BAND ///////////////////////////////////////////////////////////////// r1_5=r1*5; r2_5=r2*5; m_5= MACD(r1_5, r2_5); s_5= Signal(r1_5,r2_5,r3); r1_10=r1*10; r2_10=r2*10; m_10= MACD(r1_10, r2_10); s_10= Signal(r1_10,r2_10,r3); r1_20=r1*20; r2_20=r2*20; m_20= MACD(r1_20, r2_20); s_20= Signal(r1_20,r2_20,r3); r1_40=r1*40; r2_40=r2*40; m_40= MACD(r1_40, r2_40); s_40= Signal(r1_40,r2_40,r3); r1_80=r1*80; r2_80=r2*80; m_80= MACD(r1_80, r2_80); s_80= Signal(r1_80,r2_80,r3); ColorT=IIf(m1>0,IIf(m1>s1,colorBrightGreen,colorDarkRed),IIf(m10,IIf(m_5>s_5,colorBrightGreen,colorDarkGreen),IIf(m_5 0,IIf(m_10>s_10,colorBrightGreen,colorDarkGreen),IIf(m_10 0,IIf(m_20>s_20,colorBrightGreen,colorDarkGreen),IIf(m_20 0,IIf(m_40>s_40,colorBrightGreen,colorDarkGreen),IIf(m_40 0,IIf(m_80>s_80,colorBrightGreen,colorDarkGreen),IIf(m_80