if (currentMinuteTimestamp !== ohlcPrice.time) { newOhlcPrice.open = newOhlcPrice.high = newOhlcPrice.low = price; newOhlcPrice.time = currentMinuteTimestamp as UTCTimestamp; } else { if (price > ohlcPrice.high) newOhlcPrice.high = price; if (price < ohlcPrice.low) newOhlcPrice.low = price; } newOhlcPrice.close = price;
Explaination 1. variable ohlcPrice is the last saved ohlc price data 2. current minute but rounded off to 00 seconds 3. price is the latest price we get from websocket tick 4. newOhlcPrice is the object with OHLC data for the current tick price update (usually every second)
https://kite.trade/docs/connect/v3/market-quotes/#retrieving-ohlc-quotes
If you need per tick wise, you'll need a custom implementation for it.
Here's one I am using, this is in Javascript, please convert it to C#
const newOhlcPrice = Object.assign({}, ohlcPrice);
const currentMinuteTimestamp = Math.floor(Date.now() / 60_000) * 60;
if (currentMinuteTimestamp !== ohlcPrice.time) {
newOhlcPrice.open = newOhlcPrice.high = newOhlcPrice.low = price;
newOhlcPrice.time = currentMinuteTimestamp as UTCTimestamp;
} else {
if (price > ohlcPrice.high) newOhlcPrice.high = price;
if (price < ohlcPrice.low) newOhlcPrice.low = price;
}
newOhlcPrice.close = price;
Explaination
1. variable ohlcPrice is the last saved ohlc price data
2. current minute but rounded off to 00 seconds
3. price is the latest price we get from websocket tick
4. newOhlcPrice is the object with OHLC data for the current tick price update (usually every second)