Wrong calculation of DEMA
The formula is: DEMA = 2 ∗ E M A − E M A ( E M A )
Double exponential moving average - Wikipedia
Double exponential moving average - Wikipedia
- Adding ema_follow_index to ema_on_ema is bogus. That's not an EMA. Dividing by Period is bogus, that's not how you calculate EMA's alpha
- Your global variables are not initialized, bogus
- Don't use global variables in indicators. They are supposed to have the previous value, that means you can not process bar zero, which breaks it. bogus.
- You count up (toward past) so the indicator is repainting, bogus.
(Sorry for my bad English)
I try to calculate DEMA and I got wrong value when I compare the value of DEMA with this website (http://www.forexlive.com/LiveCharts). I have no idea about the reason that make my DEMA value different to DEMA value in the website.
I want to calculate a DEMA value with period 95 in 30 minute timeframe and below is the code I wrote. Please help :)