OPEN-SOURCE SCRIPT
Dynamic Premium & Discount Zones [AlgoNorth]

Dynamic Premium & Discount Zones
Price is deep in premium. Will it come back to the middle, or keep running? Most tools draw the zones and leave that call to you. This one gives you a number for it, from your own chart.
It splits the live swing range at its midpoint, equilibrium: above is premium, below is discount. Every candle glows back to equilibrium, pink above and cyan below, stronger the deeper price pushes. A gauge beside the last bar shows exactly where price sits in the range. Next to it, a gold figure shows how often price has made it back to equilibrium within 20 bars from the depth zone it is in now, counted from the chart you're on.
Static boxes go stale the moment price breaks a swing. Here the range updates with price on every bar, and every return is measured to the level price actually left from. Load it on the market you trade and see how often its deep zone has actually come back. Next time price stretches to the extreme, you'll know what this chart has done from there before you decide.
🔶 USAGE
🔸 Read the gauge. The gauge beside the last bar is the dealing range drawn to the price scale, premium above and discount below, with the deep bands at each end and a fill from equilibrium to price. The pill on the gauge shows the zone and position: 0% is the range low, 50% is equilibrium, 100% is the range high.
🔸 Read the glow. The glow between every candle and the equilibrium line shows which zone that bar closed in and how deep, so you can scroll back and see the whole history. Faint means near equilibrium, bright means deep in the zone, and bars that close in deep premium or deep discount get a white-hot layer.
🔸 Follow the equilibrium line. It is the 50% line of the range. A haloed dot marks each bar that closes across it.
🔸 Check the gold figure. Beside the gauge, it shows how often price traded back to equilibrium within 20 bars from the depth zone price is in now, with the count. It appears once price is at least a quarter of the way from equilibrium to the range edge.
🔸 Look for the round trips. A gold ◆ marks the bar that closes in the deep zone. A gold dot marks where price traded back to that bar's equilibrium level. A ◆ with no dot stays dimmed, so misses are as visible as returns. Only the latest round trip and the one in progress are kept on the chart.
🔸 Read the panel. The zone and position now, equilibrium and its distance in ATR, and the return rate for the current depth. Full mode lists all four depths.
🔸 Alerts: into premium, into discount, deep premium, deep discount, back to equilibrium.
🔶 DETAILS
🔸 Premium and discount. The dealing range split at its midpoint, equilibrium. Above it is premium, below it is discount. The framing comes from ICT / Smart Money Concepts; this script updates the range with price and puts a number on each zone.
🔸 Dealing range. Latest swing low to latest swing high, where a swing needs 8 bars either side. When price trades beyond an edge, that edge moves with it on the same bar, so price is always inside the range.
🔸 Equilibrium. The midpoint of the range. Smooth mode eases it between levels with a double 6-bar average and keeps it inside the range; Stepped draws the exact midpoint. In Smooth mode only, the zones follow the eased line, so for a few bars after the range changes they can differ from the exact midpoint. Stepped mode has no lag.
🔸 Depth. How far price has closed from equilibrium toward the range edge on its side, from 0 at equilibrium to 1 at the edge. Deep starts at 0.75. The deep line, the heat, the gauge bands and the panel rows all use that one level.
🔸 Depth zones. 0–25%, 25–50%, 50–75% and 75–100% deep. Premium and discount are counted together in each zone.
🔸 Measurement. Each time a bar closes in a new depth zone, the script stores that bar's equilibrium level. A return counts only if price trades back to that stored level within 20 bars. Because the level is fixed at entry, equilibrium drifting toward price during a trend does not count as a return.
🔸 Round trips. One at a time. A trip opens on the first close in the deep zone and ends when price trades back to that bar's equilibrium level or the 20-bar window closes, the same rule as the panel. Trips shorter than 3 bars are not marked.
🔸 Contrast. Every readout is checked against your chart background and switches to a legible colour automatically, on dark, light or grey charts.
🔶 SETTINGS
🔸 Dealing range: Swing length, Equilibrium line, Smoothing. Bars either side of a swing, Smooth or Stepped equilibrium, and how gently Smooth eases to a new midpoint.
🔸 Glow: Glow at candles, Mid layers, Core glow, Deep-zone heat. The strength of each layer, from the base glow to the white-hot layer on deep bars; 0 turns a layer off.
🔸 Detail: Depth contours, Equilibrium crosses, Colour candles by zone, Heat deep candles, Down candles. Colour candles by zone fills candle bodies in the zone colour; wicks and borders keep your chart's colours. The preview shows it on. It is off by default so your own candle colours are kept.
🔸 Round trips: Deep zone from, Minimum trip length, Show the latest round trip, Return window. Where the deep zone starts, the shortest trip that gets marked, and how many bars a return has to reach the stored level, for the marks and the panel alike.
🔸 Gauge: Position gauge, Price leader, Gauge offset, Gauge width. Switch the gauge and the dotted price leader on or off, and set where the gauge sits and how wide it is.
🔸 Panel: Show panel, Panel detail, Position, Text size. Compact or Full, and four corners for when more than one copy is loaded.
🔸 Colours: Premium, Discount, Highlight. Highlight is used for the ◆ marks, the return dots and the figure beside the gauge.
🔶 NOTES
🔸 Every ◆, dot, cross, alert and panel count is set at bar close, never on the forming bar, and nothing is redrawn on past bars. The gauge and the panel's live readings follow price as it moves on the current, unfinished bar.
🔸 The gold figure and panel numbers come from the bars loaded on your chart, so each symbol and timeframe shows its own numbers.
🔸 Candle colouring in the preview is an optional setting.
🔸 The panel's last-bar time is shown in exchange time, which can differ from your chart's display timezone.
🔸 Made for candle and bar charts. Chart types that redraw past bars, such as Renko or Kagi, change the history the counts are built from.
🔶 SUMMARY
A live dealing range, a glow that shows how deep price has pushed, and a gauge with a number behind it. Dynamic Premium & Discount Zones turns "will it come back?" into a question your own chart's history can answer.
Price is deep in premium. Will it come back to the middle, or keep running? Most tools draw the zones and leave that call to you. This one gives you a number for it, from your own chart.
It splits the live swing range at its midpoint, equilibrium: above is premium, below is discount. Every candle glows back to equilibrium, pink above and cyan below, stronger the deeper price pushes. A gauge beside the last bar shows exactly where price sits in the range. Next to it, a gold figure shows how often price has made it back to equilibrium within 20 bars from the depth zone it is in now, counted from the chart you're on.
Static boxes go stale the moment price breaks a swing. Here the range updates with price on every bar, and every return is measured to the level price actually left from. Load it on the market you trade and see how often its deep zone has actually come back. Next time price stretches to the extreme, you'll know what this chart has done from there before you decide.
🔶 USAGE
🔸 Read the gauge. The gauge beside the last bar is the dealing range drawn to the price scale, premium above and discount below, with the deep bands at each end and a fill from equilibrium to price. The pill on the gauge shows the zone and position: 0% is the range low, 50% is equilibrium, 100% is the range high.
🔸 Read the glow. The glow between every candle and the equilibrium line shows which zone that bar closed in and how deep, so you can scroll back and see the whole history. Faint means near equilibrium, bright means deep in the zone, and bars that close in deep premium or deep discount get a white-hot layer.
🔸 Follow the equilibrium line. It is the 50% line of the range. A haloed dot marks each bar that closes across it.
🔸 Check the gold figure. Beside the gauge, it shows how often price traded back to equilibrium within 20 bars from the depth zone price is in now, with the count. It appears once price is at least a quarter of the way from equilibrium to the range edge.
🔸 Look for the round trips. A gold ◆ marks the bar that closes in the deep zone. A gold dot marks where price traded back to that bar's equilibrium level. A ◆ with no dot stays dimmed, so misses are as visible as returns. Only the latest round trip and the one in progress are kept on the chart.
🔸 Read the panel. The zone and position now, equilibrium and its distance in ATR, and the return rate for the current depth. Full mode lists all four depths.
🔸 Alerts: into premium, into discount, deep premium, deep discount, back to equilibrium.
🔶 DETAILS
🔸 Premium and discount. The dealing range split at its midpoint, equilibrium. Above it is premium, below it is discount. The framing comes from ICT / Smart Money Concepts; this script updates the range with price and puts a number on each zone.
🔸 Dealing range. Latest swing low to latest swing high, where a swing needs 8 bars either side. When price trades beyond an edge, that edge moves with it on the same bar, so price is always inside the range.
🔸 Equilibrium. The midpoint of the range. Smooth mode eases it between levels with a double 6-bar average and keeps it inside the range; Stepped draws the exact midpoint. In Smooth mode only, the zones follow the eased line, so for a few bars after the range changes they can differ from the exact midpoint. Stepped mode has no lag.
🔸 Depth. How far price has closed from equilibrium toward the range edge on its side, from 0 at equilibrium to 1 at the edge. Deep starts at 0.75. The deep line, the heat, the gauge bands and the panel rows all use that one level.
🔸 Depth zones. 0–25%, 25–50%, 50–75% and 75–100% deep. Premium and discount are counted together in each zone.
🔸 Measurement. Each time a bar closes in a new depth zone, the script stores that bar's equilibrium level. A return counts only if price trades back to that stored level within 20 bars. Because the level is fixed at entry, equilibrium drifting toward price during a trend does not count as a return.
🔸 Round trips. One at a time. A trip opens on the first close in the deep zone and ends when price trades back to that bar's equilibrium level or the 20-bar window closes, the same rule as the panel. Trips shorter than 3 bars are not marked.
🔸 Contrast. Every readout is checked against your chart background and switches to a legible colour automatically, on dark, light or grey charts.
🔶 SETTINGS
🔸 Dealing range: Swing length, Equilibrium line, Smoothing. Bars either side of a swing, Smooth or Stepped equilibrium, and how gently Smooth eases to a new midpoint.
🔸 Glow: Glow at candles, Mid layers, Core glow, Deep-zone heat. The strength of each layer, from the base glow to the white-hot layer on deep bars; 0 turns a layer off.
🔸 Detail: Depth contours, Equilibrium crosses, Colour candles by zone, Heat deep candles, Down candles. Colour candles by zone fills candle bodies in the zone colour; wicks and borders keep your chart's colours. The preview shows it on. It is off by default so your own candle colours are kept.
🔸 Round trips: Deep zone from, Minimum trip length, Show the latest round trip, Return window. Where the deep zone starts, the shortest trip that gets marked, and how many bars a return has to reach the stored level, for the marks and the panel alike.
🔸 Gauge: Position gauge, Price leader, Gauge offset, Gauge width. Switch the gauge and the dotted price leader on or off, and set where the gauge sits and how wide it is.
🔸 Panel: Show panel, Panel detail, Position, Text size. Compact or Full, and four corners for when more than one copy is loaded.
🔸 Colours: Premium, Discount, Highlight. Highlight is used for the ◆ marks, the return dots and the figure beside the gauge.
🔶 NOTES
🔸 Every ◆, dot, cross, alert and panel count is set at bar close, never on the forming bar, and nothing is redrawn on past bars. The gauge and the panel's live readings follow price as it moves on the current, unfinished bar.
🔸 The gold figure and panel numbers come from the bars loaded on your chart, so each symbol and timeframe shows its own numbers.
🔸 Candle colouring in the preview is an optional setting.
🔸 The panel's last-bar time is shown in exchange time, which can differ from your chart's display timezone.
🔸 Made for candle and bar charts. Chart types that redraw past bars, such as Renko or Kagi, change the history the counts are built from.
🔶 SUMMARY
A live dealing range, a glow that shows how deep price has pushed, and a gauge with a number behind it. Dynamic Premium & Discount Zones turns "will it come back?" into a question your own chart's history can answer.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.