Reversing MACD
In his article “Reversing MACD”, Johnny Dough showed that the reversing MACD can be used to calculate the price value of a specific MACD level and the price value that will cause the MACD to change direction.
Using Tradecision’s Function Builder, one needs to create the following functions:
PMACDeq function:
function (price:numeric, period_x:numeric,
period_Y:numeric):Numeric;
Var
alphaX:= 2 / ( 1 + period_X );
alphaY:= 2 / ( 1 + period_Y );
End_var
return ( EMA( price, period_X ) * alphaX -
EMA( price, period_Y )* alphaY ) /
( alphaX - alphaY );
PMACDlevel function:
function (level:numeric,price:numeric,
period_x:numeric, period_Y:numeric):Numeric;
var
alphaX := 2 / ( 1 + period_X );
alphaY := 2 / ( 1 + period_Y );
One_alphaX := 1 - alphaX;
One_alphaY := 1 - alphaY;
end_var
return ( level + EMA( price, period_Y ) *
One_alphaY - EMA( price, period_X )*
One_alphaX ) / ( alphaX - alphaY );
PMACDzero function:
function (price:numeric, period_x:numeric,
period_Y:numeric):Numeric;
return PMACDlevel( 0 , price, period_X, period_Y );
Using Tradecision’s Indicator Builder, one needs to create the following indicators:
PMACDzero indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
End_input
return PMACDeq(p_px, p_fast, p_slow );
EMA_PMACD indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
End_input
return EMA(PMACDeq(p_px, p_fast, p_slow ),p_signal);
PMACD_level indicator:
Inputs
p_px: "Price field", Close;
P_level: "Price level", 1, 0, 52;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
End_input
return PMACDlevel(p_level,p_px,p_fast,p_slow);
PMACD_BBBottom indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
p_bbperiod: "BB period", 10;
p_bbwidth: "BB width", 1;
End_input
return BBBot(PMACDeq(p_px, p_fast, p_slow ),
p_bbperiod, p_bbwidth);
PMACD_BBTop indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
p_bbperiod: "BB period", 10;
p_bbwidth: "BB width", 1;
End_input
return BBTop(PMACDeq(p_px, p_fast, p_slow ),
p_bbperiod, p_bbwidth);
PMACD_BBMiddle indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
p_bbperiod: "BB period", 10;
p_bbwidth: "BB width", 1;
End_input
return (BBBot(PMACDeq(p_px, p_fast, p_slow ),
p_bbperiod, p_bbwidth) + BBTop(PMACDeq(p_px,
p_fast, p_slow ), p_bbperiod, p_bbwidth)) / 2;
PMACD_MTF_fast indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
End_input
Var
X:= 21;
End_var
return PMACDeq( p_px, X * p_fast, X * p_slow );
PMACD_MTF_slow indicator:
Inputs
p_px: "Price field", Close;
p_fast: "Period fast", 12, 1, 24;
p_slow: "Period slow", 26, 2, 52;
p_signal: "Period signal", 9, 0, 18;
End_input
Var
X:= 5;
End_var
return PMACDeq( p_px, X * p_fast, X * p_slow );
|