Nicolas

ALMA MACD

Category: Indicators By: Nicolas Created: September 17, 2016, 1:22 PM
September 17, 2016, 1:22 PM
Indicators
7 Comments
ALMA MACD

This technical indicator is the classical MACD (Moving Average Convergence Divergence) made with ALMA (Arnaud Legoux Moving Average) which formula can be found here in the Library: http://www.prorealcode.com/prorealtime-indicators/alma-arnaud-legoux-moving-average/  , instead of the normal MA.

Since this type of moving average considerably reduce lags, I thought it could be useful to rewrite the MACD with it.

Results are great on chart, the indicator react quickly than the classic MACD. While it can be accurate to detect new turning point of the trend, the false signals are reduced because of its quick adaptation to the price movement.

//PRC_ALMA MACD | indicator
//17.09.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

//parameters
// Sigma = 4
// Offset = 0.85
// Fast = 12
// Slow = 26
// Signal = 9

Price = customclose

//---Fast MA
m = (Offset * (Fast - 1))
s = Fast/Sigma
WtdSum = 0
CumWt  = 0
for k = 0 to Fast - 1 do
 Wtd = Exp(-((k-m)*(k-m))/(2*s*s))
 WtdSum = WtdSum + Wtd * Price[Fast - 1 - k]
 CumWt = CumWt + Wtd
next
FastMA = WtdSum / CumWt

//---Slow MA
n = (Offset * (Slow - 1))
t = Slow/Sigma
SWtdSum = 0
SCumWt  = 0
for k = 0 to Slow - 1 do
 SWtd = Exp(-((k-n)*(k-n))/(2*t*t))
 SWtdSum = SWtdSum + SWtd * Price[Slow - 1 - k]
 SCumWt = SCumWt + SWtd
next
SlowMA = SWtdSum / SCumWt

//---MACD
ALMAMACD = FastMA-SlowMA

//---Signal MA
n = (Offset * (Signal - 1))
t = Signal/Sigma
SWtdSum = 0
SCumWt  = 0
for k = 0 to Signal - 1 do
 SWtd = Exp(-((k-n)*(k-n))/(2*t*t))
 SWtdSum = SWtdSum + SWtd * ALMAMACD[Signal - 1 - k]
 SCumWt = SCumWt + SWtd
next
SignalMACD = SWtdSum / SCumWt

RETURN ALMAMACD as "ALMA MACD", SignalMACD as "Signal line"

Download
Filename: PRC_ALMA-MACD.itf
Downloads: 535
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

JMat45
7 years ago
#

Hi Nicolas, just reviewing this indicator and noticed that you have double assigned the variables n, t, SWtdSum and SCumWt under the 'Slow MA' and 'Signal MA' sections - is that intended or should the variable names be different?

Nicolas
7 years ago
#

That would not make any difference because the code is read from top to bottom.

Arnaud HALVICK
8 years ago
#

Great indicator, thank you!

Abz
Abz
9 years ago
#

Hi , is it possible to write this code in Excel? i have some data in excel i want to test this against.

Nicolas
9 years ago
#

Should be possible in VBA, I can do it as a job with the programming services: https://www.prorealcode.com/trading-programming-services/

Abz
Abz
10 years ago
#

Hello Nicolas

to backtest this with some stock or commodities how woud you reccomend to test it ? when the lines crosses eachother go long or short but ho identify that they are overbought and oversold

Nicolas
10 years ago
#

This is only a classic MACD made with ALMA moving average. So you can trade it just like any other MACD. MACD doesn't spot overbought or oversold areas, it's a trend indicator, made of differences of 2 moving average values (1 short and 1 long period).

ProRealCode ProRealCode
Loading...