DEMA is not working with backtest properly - page 2

 

Having done that it is easy to see why the original coder wanted to do it with static doubles, it seems like overkill to write all the EMA and EMAEMA values into buffers when all you need from them is one value, I'm going to write it again with static doubles.

 
Think about what happens when you miss the last tick of bar zero and a new bar forms. Your loop tries to calculate the final value of bar 1 using the current bar 1 statics. Bogus result.
 

Yes i know lol, I was about to post to say I changed my mind about it for that very reason. It didn't occur to me untill I started to write it :D

Reason: