Moving average calculations

VinayAkuthota
Hi Team,
Can anyone let me know how moving average is calculated in kite.
display Candle and 1 minute graph

i am loading the live data to Database and calculating the moving averages But seams the calculations are odd. Can someone tell me what is the logic used in zerodha

example:
For moving average 6 i used below query
select token, CAST(avg(price) AS numeric(10,2)) AS avg_6 FROM ticks
WHERE date > (CURRENT_TIMESTAMP - ((6 || ' minutes'::text)::interval))
GROUP BY token


For moving average 10 i used below query
select token, CAST(avg(price) AS numeric(10,2)) AS avg_10 FROM ticks
WHERE date > (CURRENT_TIMESTAMP - ((10 || ' minutes'::text)::interval))
GROUP BY token

For moving average 12 i used below query
select token, CAST(avg(price) AS numeric(10,2)) AS avg_12 FROM ticks
WHERE date > (CURRENT_TIMESTAMP - ((12|| ' minutes'::text)::interval))
GROUP BY token
Tagged:
Sign In or Register to comment.