Reverse MACD

#3
I think this person was asking for the AFL code: your link to the article doesn't include any AFL. Actually there was a typo in traders.com "trader's tip" link: you get the reversing MACD code for every software but NOT Amibroker. The code in the article is algebra, not AFL. I am myself looking for this AFL as well...
 

KelvinHand

Well-Known Member
#4
The above Picture MACD Code -

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorDefault ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
Somebody already created the ReverseMACD:
http://www.traderji.com/amibroker/77416-reverse-macd-amibroker-4.html
 

gkpc

Well-Known Member
#5
I think this person was asking for the AFL code: your link to the article doesn't include any AFL. Actually there was a typo in traders.com "trader's tip" link: you get the reversing MACD code for every software but NOT Amibroker. The code in the article is algebra, not AFL. I am myself looking for this AFL as well...
Well I almost typed a welcome to traderji message for you ! :eek:
Then realised that you have joined in 2010 :D
BUT
this is your first post !!! :p

Its a bit surprising ! :D
 

johnnypareek

Well-Known Member
#6
Does anyone have amibroker afl code for Reversing MACD by Johnny Dough
http://www.traders.com/Documentation/FEEDbk_docs/2012/01/Dough.html
HTML:
_SECTION_BEGIN("REVERSING_MACD_INDICATOR_WINDOW");
t1= Param("fast periods", 12, 5,  24);
t2= Param("slow periods", 26, 10, 52);
t3= Param("signal periods", 9,3, 18);

pick= ParamList("plot", "MACD|MACD_HLC|MACD_MTF");

MACDH=EMA(H,t1)-EMA(H,t2);
MACDL=EMA(L,t1)-EMA(L,t2);
MACDC=EMA(C, t1)- EMA(C,t2);
MTFw= EMA(C,5*t1) - EMA(C,5*t2);
MTFM= EMA(C,21*t1)- EMA(C,21*t2);

Sig= EMA(MACDC,t3);

Plot(MACDC, "MACD",   colorBlue);
Plot(Sig,   "Signal", colorRed);
Plot(0,     "",      colorGrey40);
     

switch (pick)
{
  case "MACD_HLC":
     Plot(MACDH, "MACDH",   colorGreen);
     Plot(MACDL, "MACHL",   colorDarkYellow);
     break; 
     
  case "MACD_MTF":
     Plot(MTFw, "MTFw",   colorGreen);
     Plot(MTFm, "MTFm",   colorDarkYellow);
     break;

  default /*MACD*/:
      diff = MACDc- sig;
     Plot(diff, "Diff",   colorTeal, styleHistogram);
     break;
 
}
_SECTION_END();
 
#7
code for reverse macd:
HTML:
_SECTION_BEGIN("Surrogate");
BarLum1 		= Param("Short TF Bar Color Intensity", 0.2, 0, 1, 0.01);
LineColor 		= ColorBlend(colorBlack, colorWhite, BarLum1);
UpBarColor		= ColorBlend(colorBrightGreen, colorWhite, BarLum1);
DnBarColor		= ColorBlend(colorRed, colorWhite, BarLum1);
Surrogate= Param( "Surrogate", 6, 1,30,1 );
p=6;
Om=MA(O,Surrogate);
hm=MA(H,Surrogate);
lm=MA(L,Surrogate);
Cm=MA(C,Surrogate);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );
BarColor	= IIf(HACLOSE> HaOpen , UpBarColor, DnBarColor);
SetBarFillColor(BarColor);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), LineColor, styleCandle | styleNoLabel );

_SECTION_END();
_SECTION_BEGIN(" REVERSING MACD");
gxs=Param("GRAPH spaceing",5,-10,40,1); 
GraphXSpace = gxs;
t1 = Param("fast periods", 12,5, 24, 12);
t2 = Param("slow periods", 26,10, 52, 26);
t3 = Param("signal periods", 9,3, 18, 9);
pick = Param("plot: <1=MACDeq 2=MACDeq0 3=HLC 4=BBands>",2,1,4,1);
a1 = 2/(t1+1);
a2 = 2/(t2+1);
CMACDeq = (Ref(EMA(C,t1)*a1,-1)-Ref(EMA(C,t2)*a2,-1))/(a1-a2);
HMACDeq = (Ref(EMA(H,t1)*a1,-1)-Ref(EMA(H,t2)*a2,-1))/(a1-a2);
LMACDeq = (Ref(EMA(L,t1)*a1,-1)-Ref(EMA(L,t2)*a2,-1))/(a1-a2);
MACDeq0 = Ref(EMA(C,t2)*(1-a2) - EMA(C,t1)*(1-a1),-1)/(a1-a2);
z = LastValue(IIf(pick > 2, 0, Cum(1)+1));
plot1 = IIf(pick==3, HMACDeq, BBandTop(CMACDeq,10,1));
plot2 = IIf(pick==2, MACDeq0, CMACDeq);
plot3 = IIf(pick==3, LMACDeq, BBandBot(CMACDeq,10,1));
Plot(plot1+ Ref(0,z),"HMACDeq",colorGreen,styleThick);
Plot(plot3+ Ref(0,z),"LMACDeq",colorRed,styleThick);
Rmacdcolor=IIf(MACDeq0<= C, ParamColor("Rmacdup", colorGreen),ParamColor("Rmacddn", colorRed));
Plot(plot2,"MACDeq0",Rmacdcolor,styleLine);
Colmacdeq=IIf(C>HMACDeq,colorLime,IIf(C<LMACDeq,colorOrange,colorDarkYellow));
Plot(CMACDeq,"CMACDeq ",colmacdeq,8);
_SECTION_END();
 

Similar threads