juanj

ZeroLag MACD Divergence Signals

Category: Indicators By: juanj Created: May 22, 2020, 2:32 PM
May 22, 2020, 2:32 PM
Indicators
5 Comments
ZeroLag MACD Divergence Signals

This is another spin of the classic MACD divergence indicator except we use a zero lag MACD and also consider the immediate price action to filter for stronger signals.

The only adjustable parameter is the lookback period to consider for calculating the divergence between price and the MACD crossover.

Note that the indicator only loads 5000 bars per default in order to load faster but this can easily be changed in the code if required.

Defparam CalculateOnLastBars = 5000

MACD1 = DEMA[12](close) //Moving Average 1
MACD2 = DEMA[26](close) //Moving Average 2
MACDSource = MACD1 - MACD2
MACDSignal = DEMA[9](MACDSource) //MACD Signal Line

DivergencePeriod = 20

If MACDSignal > 2 and MACDSignal[1] <= MACDSource[1] and MACDSignal >= MACDSource Then
 MACDCrossHigh = MACDSignal
ElsIf MACDSignal < -2 and MACDSignal[1] >= MACDSource[1] and MACDSignal <= MACDSource Then
 MACDCrossLow = MACDSignal
EndIf

If MACDCrossHigh < MACDCrossHigh[DivergencePeriod] and close > close[DivergencePeriod] and (high-max(open,close) > (max(open,close)-min(open,close)) or (close[1] > open[1] and close < min(open,close))) Then
 Divergence = -1
 r = 255
 g = 0
ElsIf MACDCrosslow > MACDCrossLow[DivergencePeriod] and close < close[DivergencePeriod] and (min(open,close)-low > (max(open,close)-min(open,close)) or (close[1] < open[1] and close > max(open,close))) Then
 Divergence = 1
 r = 0
 g = 255
Else
 Divergence = 0
 r = 0
 g = 0
EndIf

Return Divergence coloured(r,g,0) style(histogram) as "Divergence"

 

Download
Filename: Custom-ZeroLag-MACD-Divergence-1.itf
Downloads: 373
juanj
juanj Master
My name is Juan Jacobs and I am an algorithmic trader and trading coach. After 7 years of corporate work as a Systems Analyst, I have decided to pursue my passion of trading on a full-time basis. My current focus area is that of 'smart' strategies based on 'Machine Learning'. You can find me at www.FXautomate.com or visit my PRC Marketplace Store here: https://market.prorealcode.com/store/fxautomate/
Author’s Profile

Comments

juanj
6 years ago
#

Please note that the indicator is meant for PRT 10.3

ggolfet
6 years ago
#

it seems it's not working on prorealtime 11. I changed MACDSignal to MACDSign in order to avoid running errors. However the indicator does not print anything. Any info for fixing this issue? thanks

larouedegann
6 years ago
#

It doesn't work

Stenozar
6 years ago
#

Hi Juanj e thanks for your indicator; do you suggest any timeframe for a better use of it? thanks

Violet
6 years ago
#

Is there perhaps a problem with the code? It doesn't work, at least not on my PRT version 11

ProRealCode ProRealCode
Loading...