Pine script 为24小时交易创建一个自动重置的VWAP
我交易ES,这是一个24小时的市场 我注意到,由于24小时交易的性质,标准VWAP的工作效率不高 所以我尝试创建一个新的VWAP,它在每次会话后都会重置。因此,它在正常工作时间(09:30-16:00)有一个VWAP,然后在16:00-09:30之间重置并计算一个新的VWAP 我有代码来区分营业日和隔夜市场:Pine script 为24小时交易创建一个自动重置的VWAP,pine-script,Pine Script,我交易ES,这是一个24小时的市场 我注意到,由于24小时交易的性质,标准VWAP的工作效率不高 所以我尝试创建一个新的VWAP,它在每次会话后都会重置。因此,它在正常工作时间(09:30-16:00)有一个VWAP,然后在16:00-09:30之间重置并计算一个新的VWAP 我有代码来区分营业日和隔夜市场: t = time(period, "0930-1600") mkt_hours = na(t) ? na : 1 以下是计算一定时期内VWAP的代码: cumulativePeriod
t = time(period, "0930-1600")
mkt_hours = na(t) ? na : 1
以下是计算一定时期内VWAP的代码:
cumulativePeriod = input(14, "Period")
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
plot(vwapValue)
但我不知道如何在每天09:30和16:00重置VWAP
有什么想法吗
干杯我正在寻找类似的东西,以允许锚定VWAP。我已经能够通过手动指定用于锚定VWAP的条号来解决这个问题,但是没有任何运气返回特定时间或条件的编号。理想情况下,我希望从会话低或会话高运行VWAP 以下是Jayy的tradingview研究中的代码,用于按定义的时间或条数锚定vwap
startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP",
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )
v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)
startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)
Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)
middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)