如何在pinescript中获取周五收盘价
How to get the price of Friday close in pinescript
我正在尝试使用此代码存储周五收盘价:
study("My Script")
endOfDay = 1600 //session end, in exchange local time, in 24hours format: 9:30AM=930, 4pm=1600
lastBarOfDay = (hour(time_close)*60 + minute(time_close)==(60*(endOfDay/100)+endOfDay%100))?1:0
friclose=0.0
friclose := dayofweek == 6 and lastBarOfDay? security(syminfo.tickerid, "D",close) : friclose[1]
plot(friclose)
它适用于每日时间范围,但是如果我切换到任何日内时间范围,收盘价都不正确,我不明白为什么会这样?
或者谁知道有更好的方法来获取每周周五的收盘价,并且只在当前周五收盘后更新它。
closingHour = input(16)
closingMinute = input(00)
sessionCloseTime = timestamp(year, month, dayofmonth, closingHour, closingMinute)
bool isLastBarOfWeek = false
if timeframe.isintraday and dayofweek == dayofweek.friday
lastBarTime = sessionCloseTime - timeframe.multiplier * 60000
isLastBarOfWeek := time >= lastBarTime
float FridayClose = na
if barstate.isconfirmed and isLastBarOfWeek
FridayClose := close
else
FridayClose := FridayClose[1]
plot(FridayClose)
我正在尝试使用此代码存储周五收盘价:
study("My Script")
endOfDay = 1600 //session end, in exchange local time, in 24hours format: 9:30AM=930, 4pm=1600
lastBarOfDay = (hour(time_close)*60 + minute(time_close)==(60*(endOfDay/100)+endOfDay%100))?1:0
friclose=0.0
friclose := dayofweek == 6 and lastBarOfDay? security(syminfo.tickerid, "D",close) : friclose[1]
plot(friclose)
它适用于每日时间范围,但是如果我切换到任何日内时间范围,收盘价都不正确,我不明白为什么会这样?
或者谁知道有更好的方法来获取每周周五的收盘价,并且只在当前周五收盘后更新它。
closingHour = input(16)
closingMinute = input(00)
sessionCloseTime = timestamp(year, month, dayofmonth, closingHour, closingMinute)
bool isLastBarOfWeek = false
if timeframe.isintraday and dayofweek == dayofweek.friday
lastBarTime = sessionCloseTime - timeframe.multiplier * 60000
isLastBarOfWeek := time >= lastBarTime
float FridayClose = na
if barstate.isconfirmed and isLastBarOfWeek
FridayClose := close
else
FridayClose := FridayClose[1]
plot(FridayClose)