historical api candle for EMA calculation

visasimbu
I was trying to calculate EMA using zerodha historical_data. The numbers what i am calculating is not matching with tradingview. Then I come to know that trading view calculating using past 2000 candles where as i am calculating from past 300 candles which was leading to this mismatch of my EMA number.

Is there any way to get even more candle from zerodha ? or what is the available option on this EMA calculation where i can get nearest number of tradingview. Please throw me some light on this.
tz = pytz.timezone("Asia/Kolkata")
now = datetime.now(tz)

to_date = now.replace(minute=15, second=00, microsecond=0)
from_date = to_date - timedelta(days=360)

historical = self.kite.historical_data(
instrument_token=self.instrument_token,
from_date=from_date,
to_date=to_date,
interval="60minute"
)
Even above code brings only 308 candles of 1 hour. using this data i am calculating EMA using below lines.
alpha = 2 / (50 + 1)
df['hlc3'] = (df['high'] + df['low'] + df['close']) / 3
df['ema_50'] = df['hlc3'].ewm(alpha=alpha, adjust=False).mean()
Trading view was using

ema = ta.ema(hlc3, 50)
  • visasimbu
    I found that only 300 candle is coming from zerodha historical api ? even i try to perform pagination. In that case, older dates i got as 0 data.

    Is there any restrictions on accessing older data in zerodha ?
Sign In or Register to comment.