2

我交易的是 24 小时市场的 ES。

我注意到由于 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 = 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。

有任何想法吗?

干杯

4

1 回答 1

1

我正在寻找类似的东西以允许锚定 VWAP。我已经能够通过手动指定条号来锚定 VWAP 来解决这个问题,但是没有运气返回特定时间或条件的条号。IE。理想情况下,我想从会话低或会话高运行 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)
于 2018-11-13T05:18:46.180 回答