如何获取当前日期的时间戳? yearCTD,monthCTD和dateCTD都按序列返回,但时间戳记仅接受整数。
基本上是尝试每天自动锚定vwap,而不是手动更改日期。
谢谢
src = hlc3
YearCTD = year(timenow)
monthCTD = month(timenow)
dateCTD = dayofmonth(timenow)
momentCTD = timestamp(YearCTD, monthCTD, dateCTD, 9, 30) <= error due to series
startCTD = time >= momentCTD and time[1] < momentCTD
sumSrcCTD = src * volume
sumVolCTD = volume
sumSrcCTD := startCTD ? sumSrcCTD : sumSrcCTD + sumSrcCTD[1]
sumVolCTD := startCTD ? sumVolCTD : sumVolCTD + sumVolCTD[1]
plot(sumSrcCTD / sumVolCTD, title="CTD_VWAP", color=blue)
答案 0 :(得分:0)
使用v4:
//@version=4
study("", "", true)
src = hlc3
YearCTD = year(timenow)
monthCTD = month(timenow)
dateCTD = dayofmonth(timenow)
momentCTD = timestamp(YearCTD, monthCTD, dateCTD, 9, 30)
startCTD = time >= momentCTD and time[1] < momentCTD
sumSrcCTD = src * volume
sumVolCTD = volume
sumSrcCTD := startCTD ? sumSrcCTD : sumSrcCTD + sumSrcCTD[1]
sumVolCTD := startCTD ? sumVolCTD : sumVolCTD + sumVolCTD[1]
plot(sumSrcCTD / sumVolCTD, title="CTD_VWAP", color=color.blue)