I have this simple OHLC dataframe below. I want to extract when (in which minute) a new high or low (for the day/complete df) was made within 30 minutes of eachother. This action I want to log in a new dataframe. So if several new highs or lows are made in a row (within 30 minutes), the last one is logged.
8:00 would be the start of the day/dataframe so logically a new high as well as a new low is made. If high or low would be broken 15min later there would be an entry because it's within 30min (but I want to leave 8:00 for clarity, as a starter). Open and close are not important. Of course during the day theoretically a new high as well as low can be made within one minute.
open high low close
date
2022-06-29 08:00:00 30962.5 30970.0 30956.5 30958.0
2022-06-29 08:01:00 30958.0 30969.0 30956.5 30966.0
2022-06-29 08:02:00 30966.0 30984.5 30966.0 30971.5
2022-06-29 08:03:00 30971.5 30977.5 30967.5 30972.0
2022-06-29 08:04:00 30972.0 30975.0 30961.5 30961.5
So an example of the result could be
date high low
2022-06-29 08:00:00 30970.0 30956.5
2022-06-29 08:53:00 0 30869.5
2022-06-29 10:11:00 30992.0 0
2022-06-29 11:59:00 0 30873.0
2022-06-29 14:15:00 31069.0 0
2022-06-29 15:52:00 31143.5 0
Maybe a 0 for no new high/low is not too smart so I am open to suggestions about this what would be the best.
I would be very grateful for someone who can point me in the right direction. It would be awesome.
Ivob