【问题标题】:Creating a VWAP for 24 hour trading that resets itself为 24 小时交易创建可自行重置的 VWAP
【发布时间】:2018-07-13 14:51:16
【问题描述】:

我交易的是 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。

有什么想法吗?

干杯

【问题讨论】:

    标签: pine-script


    【解决方案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)
    

    【讨论】:

      猜你喜欢
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      • 1970-01-01
      • 2014-05-16
      • 1970-01-01
      相关资源
      最近更新 更多