Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
Find Out More Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Zerolag MACD for Amibroker (AFL)

Rating:
3 / 5 (Votes 3)
Tags:
oscillator, trading system, amibroker

Hi,
I came across this indicator somewhere on the net. Have been using this since three months. In my opinion, works best in trending market

I am new to this afl language. Credit goes to the original author.

Similar Indicators / Formulas

Rahul Mohindar Oscillator (RMO)
Submitted by kaiji about 8 years ago
Trending Wave 2 System
Submitted by Dryden almost 6 years ago
Price Oscillator
Submitted by ariful_islam over 7 years ago
Stochastic
Submitted by expert over 7 years ago
STOCH RSI CROSSOVER
Submitted by sonia.b almost 6 years ago
CCI ZERO CROSS WITH ALERT
Submitted by thanigay2k over 4 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("ZeroLag MACD");   
/*Xero Lag MACD(p,q,r)*/
//based on ZeroLag EMA - see Technical Analysis of Stocks and Commodities, April 2000
p = Param("P",12,3,36,2);
q = Param("Q",26,3,52,2);
r = Param("R",9,3,15,1);

EMA1= EMA(Close,p);
EMA2= EMA(EMA1,p);
Difference= EMA1 - EMA2;
ZeroLagEMAp= EMA1 + Difference;
//---------------------------------------
EMA1= EMA(Close,q);
EMA2= EMA(EMA1,q);
Difference= EMA1 - EMA2;
ZeroLagEMAq= EMA1 + Difference;
//---------------------------------------
ZeroLagMACD=ZeroLagEMAp - ZeroLagEMAq;
//---------------------------------------
// Signal line
EMA1= EMA(ZeroLagMACD,r);
EMA2= EMA(EMA1,r);
Difference= EMA1 - EMA2;
ZeroLagTRIG= EMA1 + Difference;
em_macd = EMA(zerolagMACD,5);

Plot(em_MACD,"ema",IIf(em_MACD > Ref(em_MACD,-1),colorBrightGreen,colorRed),styleThick);
Plot(zerolagMACD,"zmacd",IIf(zerolagMACD > Ref(zerolagMACD,-1),colorBrightGreen,colorRed),styleThick+styleDots);
//diff_1 = ZeroLagMACD - em_macd;
//Plot(diff_1,"hist",IIf(diff_1 > 0, colorBrightGreen, colorRed),styleHistogram);
//Plot(diff_1,"hist",IIf(diff_1 > Ref(diff_1,-1), colorBrightGreen, colorRed),styleLine);

Buy = Cover = Cross(zerolagmacd,em_macd);

Sell = Short = Cross(em_macd,zerolagmacd);
PlotShapes(Buy*shapeUpTriangle,colorYellow);
PlotShapes(Sell*shapeDownTriangle,colorYellow);
Plot(zerolagtrig,"",IIf(zerolagtrig > Ref(zerolagtrig,-1),colorAqua,colorBlue),styleDashed);

Plot(0,"",colorWhite,styleNoLabel);
a = round (zerolagMACD*100)/100;
a1 = Ref(a,-1);
diff1 = round((a - a1)*10)/10;
diff2 = round((a1 - Ref(a,-2))*10)/10;
ST33= ZeroLagMACD;
bars=50;
TR1= LLVBars(ST33,5);
COND1=TR1> 0 AND Ref(TR1,-1)==0 AND Ref(ST33,-1)<0;
TR2= IIf(COND1,Ref(ST33,-1),0);
M1= ValueWhen(COND1,ST33);
P1= ValueWhen(COND1,LLV(L,3));
DM1=M1- Ref(M1,-1);DP1=P1-Ref(P1,-1);
DT= Ref(BarsSince(COND1),-1);
POSDIV=DM1> 0 AND DP1<0 AND DT<BARS; 
TR11= HHVBars(ST33,5);
COND11=TR11> 0 AND Ref(TR11,-1)==0 AND Ref(ST33,-1)>0;
TR21= IIf(COND11,Ref(ST33,-1),0);
M11= ValueWhen(COND11,ST33);
P11= ValueWhen(COND11,HHV(H,3));
DM11=M11- Ref(M11,-1);DP11=P11-Ref(P11,-1);
DT1= Ref(BarsSince(COND11),-1);
NEGDIV=DM11< 0 AND DP11>0 AND DT1<BARS;
PlotShapes(shapeDigit3*POSDIV,colorBrightGreen);
PlotShapes(shapeDigit3*NEGDIV,colorRed);


Title =
EncodeColor(colorYellow)+"MACD              : "+ WriteIf(a > 0,  EncodeColor(colorGreen)+a,EncodeColor(colorRed)+a)
+ WriteIf(diff1 > 0, EncodeColor(colorGreen)+"  Up by "+diff1,EncodeColor(colorRed)+"  Dn by "+diff1)
+"\n"
+EncodeColor(colorYellow)+ "One bar ago   : "+ WriteIf(a1 > 0, EncodeColor(colorGreen)+a1,EncodeColor(colorRed)+a1)
+ WriteIf(diff2 > 0, EncodeColor(colorGreen)+"  Up by "+diff2,EncodeColor(colorRed)+"  Dn by "+diff2)
;
 

//===========================end zeroLagMACD
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back