以下代码可帮助客栈找到用户提到的初始范围的高值和低值。
study(title="Initial Range", shorttitle="IR", overlay=true)
ir = input(true, title="Show Initial Range")
res = input('60', type=resolution, title="Duration of Initial Range")
SessionTiming = input("0915-1530", type=session)
sessToUse= SessionTiming
bartimeSess = time('D', sessToUse)
fr2to17 = time(period, sessToUse)
is_newbar(res) => change(time(res, sessToUse)) != 0
adopt(r, s) => security(tickerid, r, s)
high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)
plot( fr2to17>0 and isintraday and ir ? adopt(res, high_range): na, title="High", style=circles,color=#FF7F00, transp=0)
plot( fr2to17>0 and isintraday and ir ? adopt(res, low_range): na, title="Low", style=circles,color=#FF7F00, transp=0)