Pine Script 获得特定日期的最高点

Pine Script get higehst high of a specific date

在我的学习中,日期是一个输入参数,我想在输入日期的“月高”上绘制一条水平线。

尝试了下面的脚本但没有得到结果,它只为当月的高点画线。请帮助实现所需的结果。

//@version=4
study(title="High of a Month", shorttitle="H_M", overlay=true) 
disMonthly = input(true, title="Show Monthly High & Lows?")
HM_Date = input(defval = timestamp("01 Jan 2021 00:00  +0530"), title = "Select Date", type = input.time)

mHigh = security(syminfo.tickerid, 'M', high[0])
plot(mHigh, title="Monthly High", style = plot.style_cross, color=color.silver,linewidth=1, trackprice = true) ````

//@version=4
study(title="High of a Month", shorttitle="H_M", overlay=true) 

disMonthly  = input(true,                     title="Show Monthly High & Lows?", type=input.bool)
HM_Date     = input(timestamp("01 Jan 2021"), title="Select Date",               type=input.time)

var float   mHigh  = na
var float   level  = na
var line    myLine = line.new(na, na, na, na, xloc.bar_time, extend.left, color.yellow, line.style_dashed, 1)

mHigh := security(syminfo.tickerid, 'M', high, lookahead=barmerge.lookahead_on)

if na(level) and time >= HM_Date
    level := mHigh
    
if barstate.islast
    line.set_xy1(myLine, time,   level)
    line.set_xy2(myLine, time+1, level)