OPEN-SOURCE SCRIPT
920 Order Flow SATY ATR

//version=6
indicator("Order-Flow / Volume Signals (No L2)", overlay=true)
//======================
// Inputs
//======================
rvolLen = input.int(20, "Relative Volume Lookback", minval=5)
rvolMin = input.float(1.1, "Min Relative Volume (× avg)", step=0.1)
wrbLen = input.int(20, "Wide-Range Lookback", minval=5)
wrbMult = input.float(1, "Wide-Range Multiplier", step=0.1)
upperCloseQ = input.float(0.60, "Close near High (0-1)", minval=0.0, maxval=1.0)
lowerCloseQ = input.float(0.40, "Close near Low (0-1)", minval=0.0, maxval=1.0)
cdLen = input.int(25, "Rolling CumDelta Window", minval=5)
useVWAP = input.bool(true, "Use VWAP Bias Filter")
showSignals = input.bool(true, "Show Long/Short OF Triangles")
//======================
// Core helpers
//======================
rng = high - low
tr = ta.tr(true)
avgTR = ta.sma(tr, wrbLen)
wrb = rng > wrbMult * avgTR
// Relative Volume
volAvg = ta.sma(volume, rvolLen)
rvol = volAvg > 0 ? volume / volAvg : 0.0
// Close location in bar (0..1)
clo = rng > 0 ? (close - low) / rng : 0.5
// VWAP (session) + SMAs
vwap = ta.vwap(close)
sma9 = ta.sma(close, 9)
sma20 = ta.sma(close, 20)
sma200= ta.sma(close, 200)
// CumDelta proxy (uptick/downtick signed volume)
tickSign = close > close[1] ? 1.0 : close < close[1] ? -1.0 : 0.0
delta = volume * tickSign
cumDelta = ta.cum(delta)
rollCD = cumDelta - cumDelta[cdLen]
//======================
// Signal conditions
//======================
volActive = rvol >= rvolMin
effortBuy = wrb and clo >= upperCloseQ
effortSell = wrb and clo <= lowerCloseQ
cdUp = ta.crossover(rollCD, 0)
cdDown = ta.crossunder(rollCD, 0)
biasBuy = not useVWAP or close > vwap
biasSell = not useVWAP or close < vwap
longOF = barstate.isconfirmed and volActive and effortBuy and cdUp and biasBuy
shortOF = barstate.isconfirmed and volActive and effortSell and cdDown and biasSell
//======================
// Plot ONLY on price chart
//======================
// SMAs & VWAP
plot(sma9, title="9 SMA", color=color.orange, linewidth=3)
plot(sma20, title="20 SMA", color=color.white, linewidth=3)
plot(sma200, title="200 SMA", color=color.black, linewidth=3)
plot(vwap, title="VWAP", color=color.new(color.aqua, 0), linewidth=3)
// Triangles with const text (no extra pane)
plotshape(showSignals and longOF, title="LONG OF",
style=shape.triangleup, location=location.belowbar, size=size.tiny,
color=color.new(color.green, 0), text="LONG OF")
plotshape(showSignals and shortOF, title="SHORT OF",
style=shape.triangledown, location=location.abovebar, size=size.tiny,
color=color.new(color.red, 0), text="SHORT OF")
// Alerts
alertcondition(longOF, title="LONG OF confirmed", message="LONG OF confirmed")
alertcondition(shortOF, title="SHORT OF confirmed", message="SHORT OF confirmed")
//────────────────────────────
// End-of-line labels (offset to the right)
//────────────────────────────
var label label9 = na
var label label20 = na
var label label200 = na
var label labelVW = na
if barstate.islast
// delete old labels before drawing new ones
label.delete(label9)
label.delete(label20)
label.delete(label200)
label.delete(labelVW)
// how far to move the labels rightward (increase if needed)
offsetBars = input.int(3)
label9 := label.new(bar_index + offsetBars, sma9, "9 SMA", style=label.style_label_left, textcolor=color.white, color=color.new(color.orange, 0))
label20 := label.new(bar_index + offsetBars, sma20, "20 SMA", style=label.style_label_left, textcolor=color.black, color=color.new(color.white, 0))
label200 := label.new(bar_index + offsetBars, sma200, "200 SMA", style=label.style_label_left, textcolor=color.white, color=color.new(color.black, 0))
labelVW := label.new(bar_index + offsetBars, vwap, "VWAP", style=label.style_label_left, textcolor=color.black, color=color.new(color.aqua, 0))
//────────────────────────────────────────────────────────────────────
//────────────────────────────────────────────
// Overnight High/Low + HOD/LOD (no POC)
//────────────────────────────────────────────
sessionRTH = input.session("0930-1600", "RTH Session (exchange tz)")
levelWidth = input.int(2, "HL line width", minval=1, maxval=5)
labelOffsetH = input.int(10, "HL label offset (bars to right)", minval=0)
isRTH = not na(time(timeframe.period, sessionRTH))
rthOpen = isRTH and not isRTH[1]
// --- Track Overnight High/Low during NON-RTH; freeze at RTH open
// --- Track Overnight High/Low during NON-RTH; freeze at RTH open
var float onHigh = na
var float onLow = na
var int onHighBar = na
var int onLowBar = na
var float onHighFix = na
var float onLowFix = na
var int onHighFixBar = na
var int onLowFixBar = na
if not isRTH
if na(onHigh) or high > onHigh
onHigh := high
onHighBar := bar_index
if na(onLow) or low < onLow
onLow := low
onLowBar := bar_index
if rthOpen
onHighFix := onHigh
onLowFix := onLow
onHighFixBar := onHighBar
onLowFixBar := onLowBar
onHigh := na, onLow := na
onHighBar := na, onLowBar := na
// ──────────────────────────────────────────
// Candle coloring + labels for 9/20/VWAP crosses
// ──────────────────────────────────────────
showCrossLabels = input.bool(true, "Show cross labels")
// Helpers
minAll = math.min(math.min(sma9, sma20), vwap)
maxAll = math.max(math.max(sma9, sma20), vwap)
// All three lines
goldenAll = open <= minAll and close >= maxAll
deathAll = open >= maxAll and close <= minAll
// 9/20 only (exclude cases that also crossed VWAP)
dcUpOnly = open <= math.min(sma9, sma20) and close >= math.max(sma9, sma20) and not goldenAll
dcDownOnly = open >= math.max(sma9, sma20) and close <= math.min(sma9, sma20) and not deathAll
// Candle colors (priority: all three > 9/20 only)
var color cCol = na
cCol := goldenAll ? color.yellow : deathAll ? color.black :dcUpOnly ? color.lime :dcDownOnly ? color.red : na
barcolor(cCol)
// Labels
plotshape(showCrossLabels and barstate.isconfirmed and goldenAll, title="GOLDEN CROSS",
style=shape.labelup, location=location.belowbar, text="GOLDEN CROSS",
color=color.new(color.yellow, 0), textcolor=color.black, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and deathAll, title="DEATH CROSS",
style=shape.labeldown, location=location.abovebar, text="DEATH CROSS",
color=color.new(color.black, 0), textcolor=color.white, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and dcUpOnly, title="DC UP",
style=shape.labelup, location=location.belowbar, text="DC UP",
color=color.new(color.lime, 0), textcolor=color.black, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and dcDownOnly, title="DC DOWN",
style=shape.labeldown, location=location.abovebar, text="DC DOWN",
color=color.new(color.red, 0), textcolor=color.white, size=size.tiny)
// ──────────────────────────────────────────
// Audible + alert conditions
// ──────────────────────────────────────────
alertcondition(goldenAll, title="GOLDEN CROSS", message="GOLDEN CROSS detected")
alertcondition(deathAll, title="DEATH CROSS", message="DEATH CROSS detected")
alertcondition(dcUpOnly, title="DC UP", message="Dual Cross UP detected")
alertcondition(dcDownOnly,title="DC DOWN", message="Dual Cross DOWN detected")
indicator("Order-Flow / Volume Signals (No L2)", overlay=true)
//======================
// Inputs
//======================
rvolLen = input.int(20, "Relative Volume Lookback", minval=5)
rvolMin = input.float(1.1, "Min Relative Volume (× avg)", step=0.1)
wrbLen = input.int(20, "Wide-Range Lookback", minval=5)
wrbMult = input.float(1, "Wide-Range Multiplier", step=0.1)
upperCloseQ = input.float(0.60, "Close near High (0-1)", minval=0.0, maxval=1.0)
lowerCloseQ = input.float(0.40, "Close near Low (0-1)", minval=0.0, maxval=1.0)
cdLen = input.int(25, "Rolling CumDelta Window", minval=5)
useVWAP = input.bool(true, "Use VWAP Bias Filter")
showSignals = input.bool(true, "Show Long/Short OF Triangles")
//======================
// Core helpers
//======================
rng = high - low
tr = ta.tr(true)
avgTR = ta.sma(tr, wrbLen)
wrb = rng > wrbMult * avgTR
// Relative Volume
volAvg = ta.sma(volume, rvolLen)
rvol = volAvg > 0 ? volume / volAvg : 0.0
// Close location in bar (0..1)
clo = rng > 0 ? (close - low) / rng : 0.5
// VWAP (session) + SMAs
vwap = ta.vwap(close)
sma9 = ta.sma(close, 9)
sma20 = ta.sma(close, 20)
sma200= ta.sma(close, 200)
// CumDelta proxy (uptick/downtick signed volume)
tickSign = close > close[1] ? 1.0 : close < close[1] ? -1.0 : 0.0
delta = volume * tickSign
cumDelta = ta.cum(delta)
rollCD = cumDelta - cumDelta[cdLen]
//======================
// Signal conditions
//======================
volActive = rvol >= rvolMin
effortBuy = wrb and clo >= upperCloseQ
effortSell = wrb and clo <= lowerCloseQ
cdUp = ta.crossover(rollCD, 0)
cdDown = ta.crossunder(rollCD, 0)
biasBuy = not useVWAP or close > vwap
biasSell = not useVWAP or close < vwap
longOF = barstate.isconfirmed and volActive and effortBuy and cdUp and biasBuy
shortOF = barstate.isconfirmed and volActive and effortSell and cdDown and biasSell
//======================
// Plot ONLY on price chart
//======================
// SMAs & VWAP
plot(sma9, title="9 SMA", color=color.orange, linewidth=3)
plot(sma20, title="20 SMA", color=color.white, linewidth=3)
plot(sma200, title="200 SMA", color=color.black, linewidth=3)
plot(vwap, title="VWAP", color=color.new(color.aqua, 0), linewidth=3)
// Triangles with const text (no extra pane)
plotshape(showSignals and longOF, title="LONG OF",
style=shape.triangleup, location=location.belowbar, size=size.tiny,
color=color.new(color.green, 0), text="LONG OF")
plotshape(showSignals and shortOF, title="SHORT OF",
style=shape.triangledown, location=location.abovebar, size=size.tiny,
color=color.new(color.red, 0), text="SHORT OF")
// Alerts
alertcondition(longOF, title="LONG OF confirmed", message="LONG OF confirmed")
alertcondition(shortOF, title="SHORT OF confirmed", message="SHORT OF confirmed")
//────────────────────────────
// End-of-line labels (offset to the right)
//────────────────────────────
var label label9 = na
var label label20 = na
var label label200 = na
var label labelVW = na
if barstate.islast
// delete old labels before drawing new ones
label.delete(label9)
label.delete(label20)
label.delete(label200)
label.delete(labelVW)
// how far to move the labels rightward (increase if needed)
offsetBars = input.int(3)
label9 := label.new(bar_index + offsetBars, sma9, "9 SMA", style=label.style_label_left, textcolor=color.white, color=color.new(color.orange, 0))
label20 := label.new(bar_index + offsetBars, sma20, "20 SMA", style=label.style_label_left, textcolor=color.black, color=color.new(color.white, 0))
label200 := label.new(bar_index + offsetBars, sma200, "200 SMA", style=label.style_label_left, textcolor=color.white, color=color.new(color.black, 0))
labelVW := label.new(bar_index + offsetBars, vwap, "VWAP", style=label.style_label_left, textcolor=color.black, color=color.new(color.aqua, 0))
//────────────────────────────────────────────────────────────────────
//────────────────────────────────────────────
// Overnight High/Low + HOD/LOD (no POC)
//────────────────────────────────────────────
sessionRTH = input.session("0930-1600", "RTH Session (exchange tz)")
levelWidth = input.int(2, "HL line width", minval=1, maxval=5)
labelOffsetH = input.int(10, "HL label offset (bars to right)", minval=0)
isRTH = not na(time(timeframe.period, sessionRTH))
rthOpen = isRTH and not isRTH[1]
// --- Track Overnight High/Low during NON-RTH; freeze at RTH open
// --- Track Overnight High/Low during NON-RTH; freeze at RTH open
var float onHigh = na
var float onLow = na
var int onHighBar = na
var int onLowBar = na
var float onHighFix = na
var float onLowFix = na
var int onHighFixBar = na
var int onLowFixBar = na
if not isRTH
if na(onHigh) or high > onHigh
onHigh := high
onHighBar := bar_index
if na(onLow) or low < onLow
onLow := low
onLowBar := bar_index
if rthOpen
onHighFix := onHigh
onLowFix := onLow
onHighFixBar := onHighBar
onLowFixBar := onLowBar
onHigh := na, onLow := na
onHighBar := na, onLowBar := na
// ──────────────────────────────────────────
// Candle coloring + labels for 9/20/VWAP crosses
// ──────────────────────────────────────────
showCrossLabels = input.bool(true, "Show cross labels")
// Helpers
minAll = math.min(math.min(sma9, sma20), vwap)
maxAll = math.max(math.max(sma9, sma20), vwap)
// All three lines
goldenAll = open <= minAll and close >= maxAll
deathAll = open >= maxAll and close <= minAll
// 9/20 only (exclude cases that also crossed VWAP)
dcUpOnly = open <= math.min(sma9, sma20) and close >= math.max(sma9, sma20) and not goldenAll
dcDownOnly = open >= math.max(sma9, sma20) and close <= math.min(sma9, sma20) and not deathAll
// Candle colors (priority: all three > 9/20 only)
var color cCol = na
cCol := goldenAll ? color.yellow : deathAll ? color.black :dcUpOnly ? color.lime :dcDownOnly ? color.red : na
barcolor(cCol)
// Labels
plotshape(showCrossLabels and barstate.isconfirmed and goldenAll, title="GOLDEN CROSS",
style=shape.labelup, location=location.belowbar, text="GOLDEN CROSS",
color=color.new(color.yellow, 0), textcolor=color.black, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and deathAll, title="DEATH CROSS",
style=shape.labeldown, location=location.abovebar, text="DEATH CROSS",
color=color.new(color.black, 0), textcolor=color.white, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and dcUpOnly, title="DC UP",
style=shape.labelup, location=location.belowbar, text="DC UP",
color=color.new(color.lime, 0), textcolor=color.black, size=size.tiny)
plotshape(showCrossLabels and barstate.isconfirmed and dcDownOnly, title="DC DOWN",
style=shape.labeldown, location=location.abovebar, text="DC DOWN",
color=color.new(color.red, 0), textcolor=color.white, size=size.tiny)
// ──────────────────────────────────────────
// Audible + alert conditions
// ──────────────────────────────────────────
alertcondition(goldenAll, title="GOLDEN CROSS", message="GOLDEN CROSS detected")
alertcondition(deathAll, title="DEATH CROSS", message="DEATH CROSS detected")
alertcondition(dcUpOnly, title="DC UP", message="Dual Cross UP detected")
alertcondition(dcDownOnly,title="DC DOWN", message="Dual Cross DOWN detected")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.