I am writing code to calculate and plot the Exponential Moving Average(EMA) for different chart timeframes(tick/1M/5M/1H etc). I found the formula for calculating EMA:
EMA = Price(t) * k + EMA(y) * (1 – k)
t = today, y = yesterday, N = number of days in EMA, k = 2/(N+1)
But I can't figure out how to factor in the timeframe into this formula. I know that the EMA plot looks different for different chart timeframes but I am unable to figure out why it is different.
To summarize with an example:
How would I go about calculating the plot points for the 5-day EMA for a candlestick chart timeframe of 5M, 15M, 1H etc?
Thank you in advance.