Hello guys,
Something must be wrong on the above code. I have firstly initialized EMA[0] to be series[0], then I use a loop to generate the other following EMA values and push back the new_EMA to the vector (or so I thought I was doing). However, it turns out that I got a whole vector of the value of series[0] instead of a new series of EMA that is supposed to emerge after the calculation of the for loop. Can anyone spot what's wrong in the code? Many thanks.
Regards,
Bosco
Of course I did. Like I said, turns out all the values in the EMA vector = new_EMA = series[0], i.e. the value that I initialized to the first value of the vector.
So it seems that the for loop was not doing what it is supposed to do, and the initial new_EMA value was kept being pushed back to the vector. That is my guess. But exactly what is wrong, I don't know...
One more you could insert printing all you variables in your function and see what values they have and how many times the loop is executed. What is the problem?!