ATR adaptive EMA

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

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: 387
Nicolas Master
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

Logo Logo
Loading...