Holt EMA

Holt EMA
The Holt EMA indicator return the Holt method of smoothing an exponential average.

You'll find in this post 2 different indicators: the first one is the Holt EMA displayed in only one color and compatible with prorealtime 10.2. The second one is the same moving average but displayd with different colors accordingly to its slope in degrees, I explain it below the first indicator code.

Coded by request on French forums.

//PRC_Holt EMA | indicator
//28.12.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//Converted from EasyLanguage version

// --- parameters
// gmma = 40
// alpha = 20
// ---

price = customclose

if alpha > 1 then
 myalpha = 2.0/(alpha+1.0)
else
 myalpha = alpha
endif
if gmma > 1 then
 mygamma = 2.0/(gmma+1)
else
 mygamma = gmma
endif

If barindex = 1 then
 value1 = price
 b = 0.0
else
 value1 = (1-myalpha)*(value1[1] + b[1]) + myalpha*price
 b = (1-mygamma)*b[1] + mygamma*(value1 - value1[1])
endif

HoltEMA = value1

return HoltEMA
 
The code uses the Holt EMA as a function, measures its slope in degrees and returns the moving average of different colors according to its degree of inclination. The ITF file of the indicator and an example of how it looks o chart is attached.

The formula of measuring the slope in degrees is rather nice I must admit. I can use it to make it rather a dynamic variation of the color in RGB type "rainbow", because here we use only 5 different colors according to inclination of the slope and conditions tested on "angle1 " and "angle2 "which are 2 parameterizable variables however. In short, a good exercise and a new addition to the library of codes for the happiness of all. I leave everyone to look at what it returns, I have not well understood if the Holt EMA has some interest on my side.
Attention this indicator with variation of color is compatible only version 10.3.

//PRC_Holt EMA Slope color | indicator
//28.12.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//Converted from EasyLanguage version

// --- parameters
//gmma = 40
//alpha = 20
//angle1 = 30
//angle2 = 60
// ---

price = customclose

if alpha > 1 then
 myalpha = 2.0/(alpha+1.0)
else
 myalpha = alpha
endif
if gmma > 1 then
 mygamma = 2.0/(gmma+1)
else
 mygamma = gmma
endif

If barindex = 1 then
 value1 = price
 K = 0.0
else
 value1 = (1-myalpha)*(value1[1] + K[1]) + myalpha*price
 K = (1-mygamma)*K[1] + mygamma*(value1 - value1[1])
endif

HoltEMA = value1

slope = atan((value1-(value1[1]+value1[2])/2)/1.5/ticksize)

condition2 = slope >= angle2
condition3 = slope >= angle1
condition4 = slope <= -1*angle2
condition5 = slope <= -1*angle1

//base color =
r=255
g=255
b=0

//conditionnal colors =
if condition2 then
 r=0
 g=102
 b=0
elsif condition3 then
 r=153
 g=255
 b=153
elsif condition4 then
 r=153
 g=0
 b=0
elsif condition5 then
 r=255
 g=153
 b=153
endif

return HoltEMA coloured(r,g,b) as "Holt EMA"
 
Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

avatar
Register or

Likes

avatar avatar
Related users ' posts
Nicolas Thanks a lot, a lot of people will find it useful! About customclose of the daily OHLC, you...
supertiti Voici un code de VIDYA construit par Sohocool : // MOYENNE EXPONENTIELLE ADAPTIVE VIDYA by ...
Matriciel Merci Supertiti. Je trouve que ce code est difficile à règler et n'est pas d'une grande pré...
Ernesto1 J'ai essayé avec deux différents I ,  a =  3 périodes et un 3 x 5 = 15 périodes.Ie comme si ...
SoloContado Hello Nicolas,   thanks a lot for your many contributions in this post. I have a prob...
Nicolas Because of no data available at the start of calculations. Add this at line 15 : if barindex...
century hi i will use it to see ... and get back to tell ya
luigi Ciao Nicolas. Approfitto di questo spazio per chiederti se puoi aiutarmi. Avrei bisogno di u...
Nicolas Si prega di utilizzare i forum per chiedere richieste di codice per favore.
triss1965@gmail.com HELP, WHY DONT I NOT GOT THE INDICATOR IN CHART. JUST UNDER?????????????
Nicolas Use the wrench on the upper left side of your price chart to add correctly indicator on PRICE.
gianlox I added a simple momentum indicator (MACD). I think much better results:   achat = 0v...
gianlox achat = 0 vente = 0 MACD12M = MACDline[12,26,9](close) MACD12S = ExponentialAverage[9](MA...
Somatolysis   Hi IGOSNELL, you´ll find other of my strategies here - but without the code - maybe...
IGOSNELL Thanks but unfortunately can't read German. If you can show that your strategies can work on...
Nicolas Thank you for contribution. Please consider that advertising is tolerate as long as you cont...
finplus Hi Wanjpt, I tried once only on AUD / USD in november 2016 during one day. No position has b...
finplus The backtest of the code works perfectly with 1 hour timeframe.
CN Anyone got a correct code for the setup?Used Minihax code with mixed results... Anyone that ...
Nicolas Ok Doc, beware of intraday, it's a battlefield full of random noises :) Maybe we can work to...
phili711 Bonjour Si la moyenne 100 est au dessus de la moyenne 20 le trend est baissier zlors pourqu...
Nicolas La comparaison se fait entre la valeur de la moyenne actuelle et telle qu'elle était il y a ...
Nicolas You have certainly apply the indicator twice on the price chart. If you want to hide one of ...
fabriziomerlo Buongiorno Nicolas,  come faccio a trasformare questo interessantissimo indicatore in uno s...
Nicolas Si desidera testare una croce sopra di 2 media mobile? Si prega di fare un argomento nel for...

Top