how to get ticks for every configurable time period like 15Minutes

sunnypatel
I am getting the ticks for every 5 seconds, can you please guide me how to get the ticks based upon configurable time period. Thanks in advance
  • tonystark
    Hi @sunnypatel,

    You can setup a timer that executes every 15 minutes. When it executes you can create a new connection, subscribe to the token, and after the first tick you can unsubscribe and disconnect.
  • sunnypatel
    can you please guide me for how to calculate open high low close for 15 minutes candle stick if I schedule my application for every 15 minutes for creating a new connection and subscribing for the token.
  • sujith
    Hi @sunnypatel,
    One of the ways is to build a 5minute candle using five 1minute candles and to build 1minute candle, you need to listen to all the ticks in a minute and create a candle.
    You can create a candle with following values for OHLC

    Open - > LTP of first candle.
    Close -> LTP of last candle.
    High -> highest LTP of that minute.
    Low -> lowest LTP of that minute.
  • sunnypatel
    so, by default the every tick is giving OHLC for a 1-minute candle?
  • sujith
    @sunnypatel,
    The Kite ticker will give you OHLC of the day.
  • sunnypatel
    hi @sujith,

    please guide me how to get a 1-minute candle from WebSocket. It would be great if you can share some code also. thanks in advance.
  • sujith
    Hi @sunnypatel,
    I am afraid, we don't have example code as of now.
    Basically, you need to store all the ticks somewhere and create candles data.
    As mentioned above,
    Value of open will be LTP of the first tick data of that minute,
    value of close will be LTP of the last tick data of that minute,
    value of high will be highest LTP of that minute,
    value of low will be lowest LTP of that minute.

    You can check out Kite ticker usage example here.
  • sunnypatel
    sunnypatel edited September 2017
    Hi @sujith,

    but I am getting the same value of open price, close price, high price and low price on every tick, but when I see the chart the values are different.

    tickerProvider.setOnTickerArrivalListener(new OnTick() {
    @Override
    public void onTick(ArrayList ticks) {

    for(Tick tick :ticks){
    // System.out.println(new Date());
    System.out.println(tick);
    }
    //tickerProvider.disconnect();
    }
    });
  • sujith
    Hi @sunnypatel,
    Both data sources are different. It is not possible for any platform to capture all the ticks over the internet.
    Check out this thread for more information.
  • sujith
    It can never match but it will be near.
  • parikshitbhinde
    parikshitbhinde edited September 2017
    @sujith why does MODE_LTP show close price (weighted average of last 30 mins of trading) not the actual last traded price. For e.g. if you check the LTP of ACC on the NSE website today, it states LTP as 1819.30 and close price as 1818.05. The Kite API data stream shows 1818.05 as LTP. Close price is good information but can be misleading for people who build strategies using LTP. Instrument token for ACC is 5633 . Thanks for your help.
  • sunnypatel
    hi @sujith,

    I am getting different values of ohlc from historical data web service in live market and after close market for 15 min candlestick can you please explain why it is like this and how to fix it

    Thanks in advance
Sign In or Register to comment.