Tuesday, January 31, 2012

Reversing MACD - Pro Real Time formula (now free again)

// Reversing MACD, Stocks & Commodities, January 2012, by Johnny Dough

// Variables: sl (days - slow), f (days - fast), t (signal - trigger)
// by default, s= 13, f = 6, t = 4
// tg = "target level"


// this is a reproduction of formulas avaible in Excel File with "translation" in Pro Real Time

// a = "alpha"
// a1 = 1 - alpha

//alpha _ fast
Af = 2/(1+f)
A1f = 1 - Af

// alpha_slow
Als = 2/(1+s)

Al1s = 1 - Als

//alpha_signal
Alt = 2/(1+t)
A1t = 1 - Alt

//EMAfast & EMAslow
// by default: the following customclose = close of the present bar
// [m, n] = period of investingation /calcolation of indicators
//
i = 0
Emafast = 0
Emaslow = 0
MACDSignal = 0
HistoMACD = 0
Emafast2 = 0
Emaslow2 = 0

for i = m to n do
    m2 = m-1
    EMAfast = Af * customclose[i] + A1f * EMAfast
    EMAslow = Als * customclose[i] + Al1s * EMAslow
    MACDA = Emafast - Emaslow
    MACDSignal = Alt * MACDA + A1t * MACDSignal
    HistoMACD = MACDA - MACDSignal + HistoMACD
    // calcolo PMACDeq, where Emafast (or slow) 2 is the previous Emafast (or slow)
    Emafast2=Af*customclose[m2] + A1f * EMAfast
    EMAslow2 = Als * customclose[m2] + Al1s * EMAslow
    PMACDeq = (Emafast2 * Af - Emaslow2 * Als)/(Af-Als)
    PMACDeqSignal = Alt*PMACDeq[i] + A1t * PMACDeq[m2]
    PMACDlevel = (tg + Emaslow2* Al1s - Emafast2*A1f)/(Af-Als)
    PMACDzero =(Emaslow2*Al1s-Emafast2*A1f)/(Af-Als)
    i = i+1
   
next



return PMACDeq  coloured(0, 0, 255) as "PMACDeq", PMACDeqSignal coloured(0, 255, 0) as "PMACDeqSignal" , PMACDzero  coloured(255, 0, 255) as "PMACDzero", PMACDlevel as "PMACDlevel"

// comments:
// only for medium range: on daily base, use to integrate other indicators only for monitoring the position of the investment
// appropried for intraday? ⇒ to evaluate
// valuate the cross of macd signals among them and prices

// valuate the cross of macd signals among them and prices


Click on image for enlarging them:






File: Reversing MACD on Excel  - click (free) here [reversing MACD with macro]
Any source

No comments:

Post a Comment