MACD BB Indicator development for Amibroker

mmca2006

Active Member
#56
Below the AFL, got it from this forum, hope it will help u.

_SECTION_BEGIN("MACD");
SetChartBkColor(ParamColor("Outer panel color ",colorBlack)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner panel color upper half",colorBlack),ParamColor("Inner panel color lower half",colorBlack)); // color of inner panel
VR = ParamToggle("indiactor On/off", "ON|OFF",1);
VOA=Param("band-period",10,5,20,1);
wid=Param("band-width",1,0.5,3,0.5);
A1=EMA(C,12)-EMA(C,26);
BBtop=BBandTop(A1,VOA,wid);
BBbot=BBandBot(A1,VOA,wid);
Color=IIf(a1<0 AND a1>Ref(a1,-1), colorLime,IIf(a1>0 AND a1>Ref(a1,-1),colorBrightGreen,IIf(a1>0 AND a1<Ref(a1,-1),colorCustom12,colorRed)));
if(VR==0)
{
Plot(a1,"MACD",color,styleDots+styleLine|styleLeftAxisScale);
Plot(BBtop,"BBtop",colorGreen,styleDashed|styleLeftAxisScale);
Plot(BBbot,"BBbot",colorRed,styleDashed|styleLeftAxisScale);
Plot(0,"",31,1|styleLeftAxisScale);}
Plot(C,"",Color,128+4);
MID=(BBTOP+BBBOT)/2;
Buy=A1>BBTOP AND Cross(a1,0) AND a1>Ref(a1,-1);
Sell=Cross(MID,a1);
Short=A1<BBBOT AND Cross(0,A1)AND a1<Ref(a1,-1);
Cover=Cross(A1,MID);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes( shapeUpArrow* Buy,colorTurquoise, 0, L, -15 );
PlotShapes( shapeHollowDownArrow* Sell, colorCustom12, 0, H, -15 );
PlotShapes( shapeHollowUpArrow* Cover,colorGreen, 0, L, -25 );
PlotShapes( shapeDownArrow* Short, colorRed, 0, H, -25 );


Filter=Buy OR Sell OR Short OR Cover;
AddColumn(IIf(Buy,66,32), "Buy", formatChar, 1,IIf(Buy,colorAqua,47));
AddColumn(IIf(Sell,83,32), "sell", formatChar, colorWhite,IIf(Sell,colorCustom12,47));
AddColumn(IIf(Short,83,32), "short", formatChar, colorWhite,IIf(Short,colorRed,47));
AddColumn(IIf(Cover,66,32), "cover", formatChar, colorWhite,IIf(Cover,colorGreen,47));

Title = EncodeColor(colorWhite)+ "MACD-BB v1.2" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" -- "+EncodeColor(colorAqua)+
WriteIf (Buy , " GO LONG at "+C+" ","")+EncodeColor(colorCustom12)+
WriteIf (Sell , " EXIT LONG at "+C+" ","")+EncodeColor(colorRed)+
WriteIf (Short , " SHORT at "+C+" ","")+EncodeColor(colorGreen)+
WriteIf (Cover , " COVER at "+C+" ","")+"\n"+
EncodeColor(colorLime)+WriteIf (a1<0 AND a1>Ref(a1,-1) , " Macd below zero line and RISING = STRENTHING "+C+" ","")+
EncodeColor(colorBrightGreen)+WriteIf (a1>0 AND a1>Ref(a1,-1) , " Macd above zero line and RISING = STRENTH++ "+C+" ","")+
EncodeColor(colorCustom12)+WriteIf (a1>0 AND a1<Ref(a1,-1) , " Macd above zero line and DECLING = weakness "+C+" ","")+
EncodeColor(colorRed)+WriteIf (a1<0 AND a1<Ref(a1,-1) , " Macd below zero line and DECLING = WEAK-- "+C+" ","");
_SECTION_END();
 
#58
Hello,
pink dots are plotted when macd is less then its previous value and it is above zero line.[ a1>0 AND a1<Ref(a1,-1),colorCustom12 ] .........red is plotted when macd is less then previos valoue and it is below zero level
i did as condition described in pdf...
Thank you
Sir, if possible please us the link of that afl, so that can also use it.
Please sir
Regards
susobhan
 

balaj78

Active Member
#59
Hi ,
This code shows error in the lines
"
if(VR==0)
{
Plot(a1,"MACD",color,styleDots+styleLine|styleLeftAxisScale);


can u please correct it

regards
bala

_SECTION_BEGIN("MACD");
SetChartBkColor(ParamColor("Outer panel color ",colorBlack)); // color of outer border
SetChartBkGradientFill( ParamColor("Inner panel color upper half",colorBlack),ParamColor("Inner panel color lower half",colorBlack)); // color of inner panel
VR = ParamToggle("indiactor On/off", "ON|OFF",1);
VOA=Param("band-period",10,5,20,1);
wid=Param("band-width",1,0.5,3,0.5);
A1=EMA(C,12)-EMA(C,26);
BBtop=BBandTop(A1,VOA,wid);
BBbot=BBandBot(A1,VOA,wid);
Color=IIf(a1<0 AND a1>Ref(a1,-1), colorLime,IIf(a1>0 AND a1>Ref(a1,-1),colorBrightGreen,IIf(a1>0 AND a1<Ref(a1,-1),colorCustom12,colorRed)));
if(VR==0)
{
Plot(a1,"MACD",color,styleDots+styleLine|styleLeftAxisScale);
Plot(BBtop,"BBtop",colorGreen,styleDashed|styleLeftAxisScale);
Plot(BBbot,"BBbot",colorRed,styleDashed|styleLeftAxisScale);
Plot(0,"",31,1|styleLeftAxisScale);}
Plot(C,"",Color,128+4);
MID=(BBTOP+BBBOT)/2;
Buy=A1>BBTOP AND Cross(a1,0) AND a1>Ref(a1,-1);
Sell=Cross(MID,a1);
Short=A1<BBBOT AND Cross(0,A1)AND a1<Ref(a1,-1);
Cover=Cross(A1,MID);

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes( shapeUpArrow* Buy,colorTurquoise, 0, L, -15 );
PlotShapes( shapeHollowDownArrow* Sell, colorCustom12, 0, H, -15 );
PlotShapes( shapeHollowUpArrow* Cover,colorGreen, 0, L, -25 );
PlotShapes( shapeDownArrow* Short, colorRed, 0, H, -25 );


Filter=Buy OR Sell OR Short OR Cover;
AddColumn(IIf(Buy,66,32), "Buy", formatChar, 1,IIf(Buy,colorAqua,47));
AddColumn(IIf(Sell,83,32), "sell", formatChar, colorWhite,IIf(Sell,colorCustom12,47));
AddColumn(IIf(Short,83,32), "short", formatChar, colorWhite,IIf(Short,colorRed,47));
AddColumn(IIf(Cover,66,32), "cover", formatChar, colorWhite,IIf(Cover,colorGreen,47));

Title = EncodeColor(colorWhite)+ "MACD-BB v1.2" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" -- "+EncodeColor(colorAqua)+
WriteIf (Buy , " GO LONG at "+C+" ","")+EncodeColor(colorCustom12)+
WriteIf (Sell , " EXIT LONG at "+C+" ","")+EncodeColor(colorRed)+
WriteIf (Short , " SHORT at "+C+" ","")+EncodeColor(colorGreen)+
WriteIf (Cover , " COVER at "+C+" ","")+"\n"+
EncodeColor(colorLime)+WriteIf (a1<0 AND a1>Ref(a1,-1) , " Macd below zero line and RISING = STRENTHING "+C+" ","")+
EncodeColor(colorBrightGreen)+WriteIf (a1>0 AND a1>Ref(a1,-1) , " Macd above zero line and RISING = STRENTH++ "+C+" ","")+
EncodeColor(colorCustom12)+WriteIf (a1>0 AND a1<Ref(a1,-1) , " Macd above zero line and DECLING = weakness "+C+" ","")+
EncodeColor(colorRed)+WriteIf (a1<0 AND a1<Ref(a1,-1) , " Macd below zero line and DECLING = WEAK-- "+C+" ","");
_SECTION_END();[/QUOTE]
 

Similar threads