我正在寻找类似的东西以允许锚定 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)