Pine Script:如何获取每个月前五个交易日的最高价

Pine Script: how do I get highest high of the first five trading days every month

我想获得每个月前五个交易日的最高价。谁能帮我解决这个问题?

//@version=5
indicator("hh from the beginning of the month", overlay = true)

var float hh = na
var int days_elapsed = na

new_month = ta.change(month) != 0
new_day = ta.change(dayofmonth) != 0

if new_month
    hh := high
    days_elapsed := 1

if new_day and not new_month
    days_elapsed += 1

if days_elapsed <= 5
    hh := math.max(hh, high)

last_months_hh = ta.valuewhen(new_month, hh[1], 0)

bgcolor(new_month ? color.yellow : na)
plot(hh)
plot(last_months_hh, color = color.silver)