The AIQ code for the reverse MACD functions and indicators described in Johnny Dough’s article in the Decmber issue of Stocks & Commodities, “Reversing MACD,” is provided at the following website: www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.
!Author: Johnny Dough, TASC January 2012
!Coded by: Richard Denning 11/9/2011
!www.TradersEdgeSystems.com
!ABBREVIATIONS:
C is [close].
H is [high].
L is [low].
O is [open].
!INPUTS:
mfast is 12.
mslow is 26.
msig is 9.
!UDFs:
emaFast is expavg(C,mfast).
emaSlow is expavg(C,mslow).
MACD is emaFast – emaSlow.
sigMACD is expavg(MACD,msig).
len_X is mfast.
len_Y is mslow.
lvl is sigMACD.
alphaX is 2 / (1 + len_X).
alphaY is 2 / (1 + len_Y).
!PLOT THE FOLLOWING AS SINGLE LINE INDICATOR ON PRICE CHART:
PMACDeq is (expavg(C,len_X)*alphaX
-expavg(C,len_Y)*alphaY)/(alphaX-alphaY).
one_alphaX is 1 – alphaX.
one_alphaY is 1 – alphaY.
PMACDlvl is (lvl+expavg(C,len_Y)*one_alphaY
– expavg(C,len_X)*one_alphaX)/(alphaX-alphaY).
!PLOT THE FOLLOWING AS SINGLE LINE INDICATOR ON UPPER CHART:
PMACDzero is (0+expavg(C,len_Y)*one_alphaY
– expavg(C,len_X)*one_alphaX)/(alphaX-alphaY).