How to store High and Low for the first 6 candles from opening (from 9. 30 am to 10 am) in 5 min candlestick time frame

I have an intraday strategy which involves comparing High and low of first 6 candles from opening (say 9.30 am to 10.00 am) with 5 EMA

I want to assign

High of today’s first 6 candles to Variable A.

Low of today’s first 6 candles to Variable B.

Then I would compare 5 EMA value with Variable A & B

If 5 EMA is higher than A, Buy signal should be generated.


If 5 EMA is lower than B, Short signal should be generated.

I guess Trade script doesn’t provide time based coding, could any one please recommend a work around for this strategy.

As per the above condition

Buy Script:

SET A = HHV(6)

Sell Script:

SET B = LLV(6)

Thank you for your answer. Yet I have a doubt though. HHV(6) will consider last 6 candles right?. I mean in a intra-day chart, if it crosses 25 candles then HHV(6) would consider candle from 19 to 25 right?. or it would still consider the first 6 candle from the beginning?.
Could you please clarify me?