Premium/Discount Zones from Rolling Range Midpoint
This indicator divides a chart into premium (above) and discount (below) zones based on the midpoint of the rolling high-low range over a specified period. Premium zones indicate price trading in the upper half of recent range; discount zones indicate the lower half. The tool is useful for mean reversion traders seeking overbought or oversold conditions, and for trend-following traders confirming directional bias relative to range equilibrium.
//@version=6
indicator("Premium/Discount Zones from Rolling Range Midpoint", overlay=true)
// Inputs
length = input.int(20, title="Rolling Range Period", minval=1)
showMid = input.bool(true, title="Show Midpoint")
showBands = input.bool(true, title="Show Range Bounds")
colorPrem = input.color(color.new(color.green, 85), title="Premium Zone Color")
colorDisc = input.color(color.new(color.red, 85), title="Discount Zone Color")
// Calculate rolling range high and low
rangeHi = ta.highest(high, length)
rangeLo = ta.lowest(low, length)
// Midpoint: arithmetic mean of range bounds
midpoint = (rangeHi + rangeLo) / 2.0
// Plot midpoint line
plot(showMid ? midpoint : na, title="Midpoint", color=color.blue, linewidth=2)
// Plot range boundaries (optional, as reference)
plot(showBands ? rangeHi : na, title="Range High", color=color.gray, linewidth=1, style=plot.style_dashed)
plot(showBands ? rangeLo : na, title="Range Low", color=color.gray, linewidth=1, style=plot.style_dashed)
// Background shading: green when price > midpoint (premium), red when price < midpoint (discount)
bgcolor(close > midpoint ? colorPrem : colorDisc, title="Zone Shading")
How the code works
The indicator retrieves the highest high and lowest low across the last length bars using ta.highest() and ta.lowest(). These form the boundaries of a rolling range window. The midpoint is their simple average: (high + low) / 2. This value represents the equilibrium price level within the recent trading range.
On each bar, the script compares the current close price to this midpoint. If close exceeds the midpoint, a premium zone is drawn (green background by default). If close is below the midpoint, a discount zone is drawn (red background by default). The midpoint itself is plotted as a blue line; optional dashed lines show the range high and low for context. All colors are user-adjustable; the range period is tunable from 1 to any value.
Reading it on a chart
Watch for transitions between zones: when price crosses from discount into premium, it signals upward momentum relative to the recent equilibrium. Conversely, a cross from premium to discount may signal weakening strength. Price that remains extended into premium zone (far from midpoint) for multiple bars can indicate potential mean reversion entry for short trades; extended discount zones may attract longs. The indicator works best in range-bound markets where the rolling midpoint remains relatively stable; in strong trends, price may sit in one zone for long periods, limiting directional signal value.
Limitations
This indicator is purely geometric and offers no predictive or probabilistic edge on its own. It repaints on every new bar as the rolling range shifts, which is normal behavior but means historical zone coloring changes as new data arrives. The indicator assumes that midpoint price represents "fair value," an assumption that breaks in persistent trends where buyers or sellers dominate; a 20-day range midpoint in a sustained uptrend will lag the market and mislead mean reversion signals. The width of premium and discount zones depends entirely on recent volatility: in quiet markets the zones are narrow (small moves cross the midpoint frequently), and in volatile markets they are wide (price may stay in one zone for many bars). No built-in filter for trend direction, so premium zone signals can conflict with trend-following logic. Performance depends heavily on parameter choice; shorter ranges are more responsive but noisier, longer ranges smooth the signal but lag price action.
Key definitions
Midpoint: The arithmetic average of the rolling period's highest high and lowest low; represents the center of equilibrium within the recent range.
Premium zone: The region where current price is above the midpoint, indicating the upper half of recent trading range.
Discount zone: The region where current price is below the midpoint, indicating the lower half of recent trading range.
Rolling range: The high and low prices recorded over a fixed number of prior bars; defines the envelope within which the midpoint is anchored.
Mean reversion: A trading approach that assumes prices that deviate from central tendency (here, the midpoint) tend to return to it over time.
References
- CME Group, "Futures Contracts Specifications", CME Learning Center. Https://www.cmegroup.com/ (general futures education and contract specs)
- Investopedia, "Support and Resistance: What's the Difference?", Investopedia. Https://www.investopedia.com/terms/s/support.asp (mid-range and equilibrium concept)
- Wilder, J. Welles, New Concepts in Technical Trading Systems, Trend Research. (1978). (foundational work on technical analysis and range analysis)
- Pine Script, "Built-in Functions Reference", TradingView Documentation. Https://www.tradingview.com/pine-script-docs/ (ta.highest, ta.lowest function definitions)
Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.
Last reviewed by the PropLedger research pipeline: 2026-10-25. Educational research on historical data, not financial advice.
Keep reading
Futures Contract Roll & Expiry Week Shading
Free open-source Pine Script indicator: contract roll and expiry week shading for futures. Full code and a plain-English walkthrough.
Session Open Anchored Move
Free open-source Pine Script indicator: session open anchored move measure (points and ATR multiples). Full code and a plain-English walkthrough.
Inside Bar and Outside Bar Highlighter
Free open-source Pine Script indicator: inside bar and outside bar highlighter. Full code and a plain-English walkthrough.