Reverse Engineering of the Zero Lag MACD
Forums › ProRealTime English forum › ProBuilder support › Reverse Engineering of the Zero Lag MACD
- This topic has 13 replies, 2 voices, and was last updated 1 year ago by Bodaris.
Tagged: zerolag MACD
-
-
01/14/2019 at 6:47 PM #88596
Hello,
For those using this indicator to trade, it may be useful to know in advance at which price the MACD will cross its signal line. Please find the code here below. If someone knows how to draw text on the right hand of the chart and not on the last candle, please shoot.
Reverse engineering of the ZMACD1234567891011121314151617181920212223242526272829303132333435363738394041defparam drawonlastbaronly=trueONCE FastAvg = 12ONCE SlowAvg = 26ONCE SigAvg = 9EMAshort1 = exponentialaverage[FastAvg](close)EMAshort2 = exponentialaverage[FastAvg](EMAshort1)DifferenceShort = EMAshort1 - EMAshort2ZeroLagShort = EMAshort1 + DifferenceShortEMAlong1 = exponentialaverage[SlowAvg](close)EMAlong2 = exponentialaverage[SlowAvg](EMAlong1)DifferenceLong = EMAlong1 - EMAlong2ZeroLagLong = EMAlong1 + DifferenceLongZeroLagMACD = ZeroLagShort - ZeroLagLongsignal1=ExponentialAverage[SigAvg](ZEROLAGMACD)signal2=ExponentialAverage[SigAvg](signal1)DIFFERENCE2=signal1-signal2SignalMACD=signal1+DIFFERENCE2alphaX=2/(1+FastAvg)alphaY=2/(1+SlowAvg)prevEMA1=ZeroLagShort[1]prevEMA2=ZeroLagLong[1]macdValue=SignalMACDpriceMACD=(macdValue+((1-alphaY)*prevEMA2)-((1-alphaX)*prevEMA1))/(alphaX-alphaY)pricerounded=round(priceMACD)drawtext("ZMACD crossing:#pricerounded#",barindex,priceMACD+2,SansSerif,Bold,10)DRAWSEGMENT(barindex-10,priceMACD,barindex,priceMACD) coloured(0,0,0)return4 users thanked author for this post.
01/14/2019 at 7:14 PM #8860401/14/2019 at 7:31 PM #8860901/15/2019 at 9:37 AM #8865302/11/2020 at 4:54 PM #119326Thank you all for sharing this code.
I have the segment in the graphic, but cannot see the price tag on the scale on the right, even if marked in the indicator parameters.
Is there anything to modify please ?
02/11/2020 at 5:29 PM #11932902/11/2020 at 6:18 PM #119330Perfect ! Thanks again guys for your quick answers 😉
04/10/2020 at 8:37 PM #125627Hi dear,
Thank’s for sharing !
I’m not using PRT but MT4 instead… I’m beginner with MQL4 langage but I’ve tried to code it, it gives me something but the line isn’t really smoothed lol.
So I don’t know if it’s normal or not…
I joined a screenshot of my result (it gives me the pink line).
And following my MQL4, maybe somebody knows this langage and could help me to analyze it :
double fastMultiplier = (2.0 / (MACD_fastAvg + 1.0) );
double slowMultiplier = (2.0 / (MACD_slowAvg + 1.0) );
double signalMultiplier = (2.0 / (MACD_sigAvg + 1.0) );//Print(“Fast Multiplier [” + fastMultiplier + “]”);
//Print(“Slow Multiplier [” + slowMultiplier + “]”);
//Print(“Signal Multiplier [” + signalMultiplier + “]”);double prevEMAShort = 0.0;
double prevEMALong = 0.0;
double prevEMASignal = 0.0;double priceMACD = 0.0;
if(i==0)
{prevEMAShort = SimpleMA(i,MACD_fastAvg,close);
prevEMALong = SimpleMA(i,MACD_slowAvg,close);
prevEMASignal = SimpleMA(i,MACD_sigAvg,close);} else {
prevEMAShort = ExtZeroLagShortDevBuffer[i-1];
prevEMALong = ExtZeroLagLongDevBuffer[i-1];
prevEMASignal = ExtZeroLagSignalDevBuffer[i-1];}
double EMAShort1 = (close[i] – prevEMAShort) * fastMultiplier + prevEMAShort;
double EMAShort2 = (EMAShort1 – prevEMAShort) * fastMultiplier + prevEMAShort;
double DifferenceShort = EMAShort1 – EMAShort2;
double ZeroLagShort = EMAShort1 + DifferenceShort;
ExtZeroLagShortDevBuffer[i] = ZeroLagShort;double EMALong1 = (close[i] – prevEMALong) * slowMultiplier + prevEMALong;
double EMALong2 = (EMALong1 – prevEMALong) * slowMultiplier + prevEMALong;
double DifferenceLong = EMALong1 – EMALong2;
double ZeroLagLong = EMALong1 + DifferenceLong;
ExtZeroLagLongDevBuffer[i] = ZeroLagLong;double ZeroLagMACD = ZeroLagShort – ZeroLagLong;
double Signal1 = (ZeroLagMACD – prevEMASignal) * signalMultiplier + prevEMASignal;
double Signal2 = (Signal1 – prevEMASignal) * signalMultiplier + prevEMASignal;
double DifferenceSignal = Signal1 – Signal2;
double SignalMACD = Signal1 + DifferenceSignal;
ExtZeroLagSignalDevBuffer[i] = SignalMACD;double macdValue = SignalMACD;
priceMACD = (macdValue+((1-slowMultiplier)*prevEMALong)-((1-fastMultiplier)*prevEMAShort))/(fastMultiplier-slowMultiplier);ExtReverseZeroLagMacdBuffer[i]=NormalizeDouble(priceMACD, InpDecimalAccurate);
04/10/2020 at 9:19 PM #12562904/10/2020 at 9:59 PM #125632NicoMich – Welcome to the forums. These forums are dedicated to the ProRealTime platform. We do not discuss other programming languages. You can use the paid for programming services for other languages if you want to. The link for it can be found under the ‘Help’ menu.
06/21/2020 at 6:27 PM #136695Bonjour,Peux-t-on avoir ce même type de reverse lorsque la ligne du MACD ZR uniquement (non pas la ligne de signal) devient croissante ou décroissante ?Merci d’avance.Hello,
Can we have this same type of reverse when the MACD ZR line only (not the signal line) becomes increasing or decreasing?
Thank you in advance.
06/21/2020 at 6:45 PM #136699- Only post in the language of the forumthat you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Thank you 😊
01/26/2022 at 11:02 PM #186680Hello,
Thank you for this very interesting code. On the other hand, I would like to display the indicator in relation to the data of the previous candle in order to identify the zone to break for the MACD to turn around. Could you let me know how to go about it?
Thank you for your help10/08/2023 at 4:23 PM #222162 -
AuthorPosts
Find exclusive trading pro-tools on