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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//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 |
Share this
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 :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
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?
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.
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
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?