timestamp of max and min value when using xbar for OHLC?

Hi,

I’m looking for an efficient way to easily grab the exacttimestamps associated with the highs and the lows within a OHLC (open, high,low, close) aggregation via xbar

For example:

select open_timestamp: first time, open:first price,high:max price, low:min price, close:last price, last_timestamp: last time by0D00:10:00.000000000 xbar time from trade where sym=XXXXXX, exg= XXXXXX

As shown above, it’s easy enough to grab the times of thefirst and the last values (open_timestamp and last_timestamp), but indexing inand getting the timestamp for the max and min values is less straight forward..

I came up with messy and verbose way to do this, butI’m sure there is a better way to do this .. via search & comparison (?) orsimilar which is eluding me at the moment.

Any ideas?

Thanks,

Bill

Something like the below might work for your case - A callback function that will be executed for each time slice, and which finds the index of the min/max price within that slice and uses that index to extract the relevant time value.

(I imagine this will be covered in Q Tips by Nick Psaris - I don’t have my copy handy)

q)t:(time:asc n?23:59;price:(n:10000)?100.0)

q)ohlc:{[t;p](t p?a;t p?b;a:min p;b:max p)}

q)select ohlc[time;price] by 10 xbar time.minute from t

Yes, this is very helpful.