ITM getting high value when open>close and store in run time

I want to write a logic to identify the high of the recent 15 min candle

ITM -1 if nifty trades at 24400 then i need to have the value of the below from 24350 CE strike
Condition 1 :- Open > close
condition 2 :- store this value of high in a runtime variable “high value”
condition 3 - use the “high value” for future trades.

Can you please help?