Gold balance zones
TAS Boxes + TAS Vega + TAS Compass
Screenshot 1 of 1 · Open image to view full size
About this script
TAS Boxes + TAS Vega + TAS Compass This toolkit combines developing value-area levels, candle coloring, and directional background shading. Each component provides a different perspective on the same market: where price is trading, whether it is moving beyond balance, and which directional bias remains active. Dynamic Value-Area Levels TAS Boxes plots three horizontal references: an upper resistance boundary, a Point of Control (POC), and a lower support boundary. In the default TradingView display, these appear in red, cyan, and green respectively. Price inside the outer boundaries is classified as balanced; a close beyond either boundary establishes a breakout condition in that direction. Candle-Based Market Classification TAS Vega translates price location into four visual states: Color Meaning Green Bullish breakout above the value area Red Bearish breakdown below the value area Orange First close back inside after trading outside Gray Subsequent closes within the value area This separates an initial return to balance from continued trading inside it. Persistent Directional Bias TAS Compass changes the chart background according to confirmed closes outside the Boxes. A close above the upper boundary establishes a green, bullish background. That bias persists until a close below the lower boundary establishes a red, bearish background. Returning inside the value area alone does not reverse the bias. Vega and Compass therefore describe different aspects of market behavior: the current bar’s relationship to value and the retained directional state. Developing and Confirmed Levels Box levels can move while a candle is forming and are finalized at its close. Distinguish these developing readings from completed-bar conditions when reviewing signals. Configurable Box Formation Three inputs govern how the value areas develop. MinSignal_123 controls the strength requirement for establishing a new Box. Length influences the momentum and price-extension conditions associated with forming new levels. MapLength determines how many bars contribute to the calculation. Increasing the first two inputs generally makes new Boxes less frequent. Changing MapLength adjusts the historical sample used to construct them. These controls allow users to explore how sensitivity and calculation history affect the resulting levels. The same framework can be examined across chart intervals, with longer intervals providing broader context and shorter intervals showing more immediate interactions with value. Level-Crossing Alerts TradingView alerts can monitor crossings of the upper value-area boundary, POC, or lower boundary. Select the relevant plotted level and crossing condition, then configure the notification settings. Descriptive alert names and messages help distinguish which instrument, timeframe, and level require attention when monitoring several charts. Flexible Chart Presentation Boxes, Vega, and Compass can be enabled together or individually. Line thickness and Vega colors are adjustable through the Style settings. A practical review begins with price location, then considers whether the latest close remains in balance, extends beyond it, or returns inside. The background bias provides an additional reference for interpreting that sequence. Use these observations within a defined trading process. A breakout classification does not establish how far price will travel, and a return to balance does not determine the next move. Entry criteria, invalidation levels, and position sizing remain part of the trader’s own rules.
Source code
Read and review the complete source before using it in your account.
script("Gold balance zones", kind="indicator")
input minSignal = 2
input length = 7
input mapLength = 7
input deviationMultiplier = 1.28
input minimumAtrWidth = 0.35
input useVolume = 1
input confirmedOnly = 1
input showBoxes = 1
input showVega = 1
input showCompass = 1
input showDashboard = 1
input dotRadius = 2
input backgroundOpacity = 0.12
input supplyColor = "#EF6355"
input centerColor = "#42BED0"
input demandColor = "#69B85A"
input bullColor = "#69D97D"
input bearColor = "#EA493A"
input returnColor = "#E6A43C"
input balanceColor = "#8D929B"
confirmBars = math.clamp(math.floor(minSignal), 1, 3)
cooldownBars = math.clamp(math.floor(length), 1, 200)
window = math.clamp(math.floor(mapLength), 2, 200)
typical = (high + low + close) / 3
safeVolume = volume > 0 ? volume : 0
volumeSum = ta.sum(safeVolume, window)
weightedPrice = typical * safeVolume
weightedSquare = typical * typical * safeVolume
priceSum = ta.sum(weightedPrice, window)
squareSum = ta.sum(weightedSquare, window)
simpleCenter = ta.sma(typical, window)
simpleDeviation = ta.stdev(typical, window)
atrValue = ta.atr(cooldownBars)
// Any missing/zero volume in the window switches the entire window to price-only mode.
missingVolume = volume > 0 ? 0 : 1
missingCount = ta.sum(missingVolume, window)
volumeReady = useVolume == 1 and volumeSum > 0 and missingCount == 0
candidateCenter = volumeReady ? priceSum / volumeSum : simpleCenter
variance = volumeReady ? math.max(0, squareSum / volumeSum - candidateCenter * candidateCenter) : 0
deviation = volumeReady ? math.sqrt(variance) : simpleDeviation
halfWidth = math.max(deviation * math.clamp(deviationMultiplier, 0.1, 5), atrValue * math.clamp(minimumAtrWidth, 0.05, 5))
ready = barIndex + 1 >= math.max(window, cooldownBars) and not na(candidateCenter) and not na(halfWidth)
confirmed = confirmedOnly == 0 or isClosed
upper = nz(upper[1], na)
center = nz(center[1], na)
lower = nz(lower[1], na)
lastBox = nz(lastBox[1], 0)
outsideUp = nz(outsideUp[1], 0)
outsideDown = nz(outsideDown[1], 0)
bias = nz(bias[1], 0)
vega = nz(vega[1], 0)
newBox = 0
if ready and confirmed {
// Confirmation compares closes with the existing box, before installing the next one.
outsideUp = not na(upper) and close > upper ? outsideUp + 1 : 0
outsideDown = not na(lower) and close < lower ? outsideDown + 1 : 0
replaceBox = na(center) or (barIndex - lastBox >= cooldownBars and (outsideUp >= confirmBars or outsideDown >= confirmBars))
if replaceBox {
center = candidateCenter
upper = center + halfWidth
lower = center - halfWidth
lastBox = barIndex
outsideUp = 0
outsideDown = 0
newBox = 1
}
direction = close > upper ? 1 : close < lower ? -1 : 0
previousVega = nz(vega[1], 0)
vega = direction != 0 ? direction : (previousVega == 1 or previousVega == -1 ? 2 : 0)
if direction != 0 {
bias = direction
}
}
visibleUpper = showBoxes == 1 ? upper : na
visibleCenter = showBoxes == 1 ? center : na
visibleLower = showBoxes == 1 ? lower : na
plot(visibleUpper, title="Supply", color=supplyColor, width=dotRadius, style="circles")
plot(visibleCenter, title="Balance center", color=centerColor, width=dotRadius, style="circles")
plot(visibleLower, title="Demand", color=demandColor, width=dotRadius, style="circles")
barcolor(showVega == 1 and not na(center) and vega == 1, color=bullColor)
barcolor(showVega == 1 and not na(center) and vega == -1, color=bearColor)
barcolor(showVega == 1 and not na(center) and vega == 2, color=returnColor)
barcolor(showVega == 1 and not na(center) and vega == 0, color=balanceColor)
compassUp = showCompass == 1 and bias == 1
compassDown = showCompass == 1 and bias == -1
bgcolor(compassUp, color=bullColor, opacity=backgroundOpacity)
bgcolor(compassDown, color=bearColor, opacity=backgroundOpacity)
if showDashboard == 1 {
table.cell("balance", 0, 0, "Gold balance zones", position="top_right")
table.cell("balance", 0, 1, volumeReady ? "Candle-volume weighted" : "Price-only · no complete volume", position="top_right")
}
alertcondition(newBox == 1 and isClosed, title="New balance box", message="New independent balance levels")
alertcondition(bias == 1 and nz(bias[1], 0) != 1 and isClosed, title="Bullish bias", message="Close above the balance box")
alertcondition(bias == -1 and nz(bias[1], 0) != -1 and isClosed, title="Bearish bias", message="Close below the balance box")
Version history
- Version 1View this version →
Discussion · 0
Support this script and join the discussion from your broker’s trading terminal using your author profile.
No comments yet.