本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//created by shyam33 to Plots VWAP and MVWAP for intraday trading. Useful to avoid whipsaws
study("VWAP MVWAP with Opening range", overlay = true)
Length = input(50)
color1 = orange
color2 = purple
mvwap = ema(vwap,Length)
plot(vwap,linewidth = 2,style = line, color = color2)
plot(mvwap,linewidth = 2,style = line,color= color1)
//created by shyam33 plot open range on different time frame
sessNum = input(0)
Open = input('0915-1530', type=session)
res = input('5', type=resolution, title="Length Of Opening Range?")
//Session Selection Rules
sessToUse = sessNum == 0 ? Open :'0915-1530'
//Session Rules
bartimeSess = (sessNum == 0 ? time('D') : time('D'))
fr0to0 = (sessNum == 0 ? time(period) : time(period))
newbarSess = bartimeSess != bartimeSess[1]
high_range = valuewhen(newbarSess,high,0)
low_range = valuewhen(newbarSess,low,0)
adopt(r, s) => security(tickerid, r, s)
//Formula For Opening Range
highRes = adopt(res, high_range)
lowRes = adopt(res, low_range)
range = highRes - lowRes
//Highlighting Line Rules For Opening Range
highColor = high > highRes ? black : black
lowColor = low < lowRes ? black : black
//Plot Statements For Opening Range Lines
openRangeHigh = plot(fr0to0 > 0 ? highRes : na, color=highColor, style=line, linewidth=1)
openRangeLow = plot(fr0to0 > 0 ? lowRes : na, color=lowColor, style=line, linewidth=1)
fill(openRangeHigh, openRangeLow, color=black, transp=90, title="Opening Range Fill")