OPEN-SOURCE SCRIPT
Playbook

//version=6
indicator('Playbook', overlay = true, scale = scale.right)
// === Inputs ===
useYesterdayPOC = input.bool(true, 'Use Yesterday\'s POC (else Today’s Developing)')
atrLength = input.int(14, 'ATR Length', minval = 1)
stretchMult = input.float(1.5, 'Stretch Threshold (in ATRs)', minval = 0.1, step = 0.1)
showBands = input.bool(true, "Show Stretch Bands")
useAnchoredVWAP = input.bool(true, "Show Anchored VWAP")
anchorDate = input.time(timestamp("01 Jan 2023 00:00 +0000"), "VWAP Anchor Date")
// === ATR ===
atr = ta.atr(atrLength)
isNewDay = ta.change(time('D')) != 0
// === VWAP as POC Approximation ===
todayVWAP = ta.vwap
var float yVWAP = na
if isNewDay
yVWAP := todayVWAP[1]
activePOC = useYesterdayPOC and not na(yVWAP) ? yVWAP : todayVWAP
// === Stretch Bands ===
upperBand = activePOC + atr * stretchMult
lowerBand = activePOC - atr * stretchMult
// Plot stretch bands
pocColor = color.yellow
bandFill = plot(upperBand, "Upper Band", color=color.red, linewidth=1, display=showBands ? display.all : display.none)
bandFill2 = plot(lowerBand, "Lower Band", color=color.green, linewidth=1, display=showBands ? display.all : display.none)
pocLine = plot(activePOC, "POC Target", color=pocColor, linewidth=2)
fill(bandFill, bandFill2, color=color.new(color.gray, 90))
// === Anchored VWAP ===
anchoredVWAP = ta.vwap(ta.change(time) >= anchorDate ? close : na)
plot(useAnchoredVWAP ? anchoredVWAP : na, "Anchored VWAP", color=color.blue, linewidth=2)
// === STATUS TABLE ===
var table statusTable = table.new(position.bottom_right, 1, 1, border_width=1, border_color=color.gray)
insideBands = close <= upperBand and close >= lowerBand
statusText = insideBands ? "WAIT" : "TRADE AVAILABLE"
statusColor = insideBands ? color.orange : color.green
table.cell(statusTable, 0, 0, statusText, text_color=color.rgb(5, 4, 4), bgcolor=statusColor)
// === Heatmap ===
bgcolor(close > upperBand ? color.new(color.red, 80) : close < lowerBand ? color.new(color.green, 80) : color.new(color.orange, 90))
indicator('Playbook', overlay = true, scale = scale.right)
// === Inputs ===
useYesterdayPOC = input.bool(true, 'Use Yesterday\'s POC (else Today’s Developing)')
atrLength = input.int(14, 'ATR Length', minval = 1)
stretchMult = input.float(1.5, 'Stretch Threshold (in ATRs)', minval = 0.1, step = 0.1)
showBands = input.bool(true, "Show Stretch Bands")
useAnchoredVWAP = input.bool(true, "Show Anchored VWAP")
anchorDate = input.time(timestamp("01 Jan 2023 00:00 +0000"), "VWAP Anchor Date")
// === ATR ===
atr = ta.atr(atrLength)
isNewDay = ta.change(time('D')) != 0
// === VWAP as POC Approximation ===
todayVWAP = ta.vwap
var float yVWAP = na
if isNewDay
yVWAP := todayVWAP[1]
activePOC = useYesterdayPOC and not na(yVWAP) ? yVWAP : todayVWAP
// === Stretch Bands ===
upperBand = activePOC + atr * stretchMult
lowerBand = activePOC - atr * stretchMult
// Plot stretch bands
pocColor = color.yellow
bandFill = plot(upperBand, "Upper Band", color=color.red, linewidth=1, display=showBands ? display.all : display.none)
bandFill2 = plot(lowerBand, "Lower Band", color=color.green, linewidth=1, display=showBands ? display.all : display.none)
pocLine = plot(activePOC, "POC Target", color=pocColor, linewidth=2)
fill(bandFill, bandFill2, color=color.new(color.gray, 90))
// === Anchored VWAP ===
anchoredVWAP = ta.vwap(ta.change(time) >= anchorDate ? close : na)
plot(useAnchoredVWAP ? anchoredVWAP : na, "Anchored VWAP", color=color.blue, linewidth=2)
// === STATUS TABLE ===
var table statusTable = table.new(position.bottom_right, 1, 1, border_width=1, border_color=color.gray)
insideBands = close <= upperBand and close >= lowerBand
statusText = insideBands ? "WAIT" : "TRADE AVAILABLE"
statusColor = insideBands ? color.orange : color.green
table.cell(statusTable, 0, 0, statusText, text_color=color.rgb(5, 4, 4), bgcolor=statusColor)
// === Heatmap ===
bgcolor(close > upperBand ? color.new(color.red, 80) : close < lowerBand ? color.new(color.green, 80) : color.new(color.orange, 90))
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。