How can we script to find highest close for a specified period?

How can we script to find highest close for a specified period?

For instance if I need to find the highest close for the past 30 days.

The syntax for above condition 

CLOSE = HHV(21)

where 21 is the number of candles