答案 0 :(得分:0)
newDay = change(time("D")) != 0
sd = stdev(close, 20)
sdDailyClose = valuewhen(newDay, sd[1], 0)
这将为您提供前一天的收盘价。
如果您想要值 AT eod,您需要知道时间范围和会话的结束时间。这假设下午 3:30 关闭(15:30)
var float closingSD = na
var int minutes = timeframe.isintraday ? 30 - timeframe.multiplier : na
sd = stdev(close, 20)
closingBarTime = timestamp(year, month, dayofmonth, 15, minutes)
if time >= closingBarTime and barstate.isconfirmed
closingSD := sd
如果你只打算在 5m 图表上使用它,你可以将它减少到这个
var float closingSD = na
sd = stdev(close, 20)
closingBarTime = timestamp(year, month, dayofmonth, 15, 25)
if time >= closingBarTime and barstate.isconfirmed
closingSD := sd