Nicolas

ATR adaptive EMA

Category: Indicators By: Nicolas Created: August 31, 2018, 12:47 PM
August 31, 2018, 12:47 PM
Indicators
4 Comments
ATR adaptive EMA

There a lot of ways how some indicators can be made adaptive instead of calculating fixed periods.

One, less known method, is to use normalized ATR (Average True Range) for making the calculation adaptive. And since EMA (Exponential Moving Average) is a a good candidate for being adaptive (it allows fractional periods for calculation), this EMA is using ATR for adaptive EMA calculations.

(author: mladen)

//PRC_ATR Adaptive EMA  | indicator
//31.08.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from Metatrader5 version

// --- settings
EmaPeriod = 20
// --- end of settings

if barindex>EmaPeriod then
 price = customclose
 atr = averagetruerange[EmaPeriod]
 start = max(1,barindex-EmaPeriod+1)
 mmax = highest[start](atr)
 mmin = lowest[start](atr)
 coeff = 1-(atr-mmin)/(mmax-mmin)
 alpha = 2.0 / (1+EmaPeriod*(coeff+1.0)/2.0)
 val  = val[1]+alpha*(price-val[1])
endif

return val

 

Download
Filename: PRC_ATR-Adaptive-EMA.itf
Downloads: 389
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

gustavobp
3 years ago
#

Buenos dias Nicolas, al agregar tu indicador no me reconoce la variable Price ni en la linea 12 ni en la 19, prorealtime al agregar el indicador me da un mensaje indicandome: "Uno de los siguientes caracteres seria mas adecuado que "PRICE: ENDIF"" No ve el error en el codigo que has creado, podrias ayudarme?

jamesoc
7 years ago
#

Hi Nicolas, do you happen to know if there is an indicator that can be applied to charts, to apply ATR volatility bands to a chart. Specifically 2.25 on a 20 EMA? I've searched but can't find anything? Thanks

Tradingrob
8 years ago
#

Hi Nicolas, when i upload this indicator in my list and use it as indicator. I get a totally different picture in my screen than what is presented here.. I cant sent you a pictre of it, but onder the graph there opens a second box, and a swirling line in it with shadow blue colours. What do i wrong?

Nicolas
8 years ago
#

Apply it on the price chart. The indicator plot just one single line. There are two in the picture to show the difference between the original EMA and this adaptive one.

ProRealCode ProRealCode
Loading...