Magic Lines (Liquidity Levels) Guide

Master this indicator with Pine Script code and automated strategies.

What is Magic Lines (Liquidity Levels)?

Searching for "The Rumers - Magic Lines"? That popular TradingView script by Silvia Rumer plots four horizontal levels - Swing High, Range High, Range Low, and Swing Low - derived from a session or lookback window. Its source code is protected (closed), so you can use it but not read or modify it. The good news: what it plots is classic liquidity-level math that any trader can reproduce. Prior-period highs and lows and swing pivot points are where stop-loss orders cluster - buy stops rest above prior highs, sell stops below prior lows. Price is repeatedly drawn to these pools, often sweeping them before reversing. Below is our own open-source Pine Script v5 equivalent (written from scratch, no protected code involved) that plots the same family of levels.

How to Use This Strategy

Pro Tip: Liquidity levels are decision zones, not automatic entries. The highest-probability pattern is the sweep-and-reclaim: price wicks through a prior day low or swing low (triggering the resting sell stops), then closes back above it - that failed breakdown is a long signal with a stop below the sweep wick. The inverse works at prior highs. Range high/low define the current battlefield: fading the edges works while price stays inside; a clean close beyond the range with volume flips you to breakout mode. Weekly levels outrank daily levels when they conflict.

Pine Script Code

Copy and paste this code into your TradingView Pine Editor.

PINE SCRIPT V5
//@version=5
indicator("Liquidity Levels", overlay=true, max_lines_count=100)

// Inputs
showDaily = input.bool(true, "Prior Day High/Low")
showWeekly = input.bool(true, "Prior Week High/Low")
pivotLen = input.int(10, "Swing Pivot Length")
rangeLen = input.int(20, "Range Lookback (bars)")

// --- Prior period highs/lows (resting liquidity) ---
pdh = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
pdl = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
pwh = request.security(syminfo.tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
pwl = request.security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)

plot(showDaily ? pdh : na, "Prior Day High", color=color.red, style=plot.style_linebr)
plot(showDaily ? pdl : na, "Prior Day Low", color=color.green, style=plot.style_linebr)
plot(showWeekly ? pwh : na, "Prior Week High", color=color.new(color.red, 40), style=plot.style_linebr, linewidth=2)
plot(showWeekly ? pwl : na, "Prior Week Low", color=color.new(color.green, 40), style=plot.style_linebr, linewidth=2)

// --- Range High / Range Low over the lookback window ---
rangeHigh = ta.highest(high, rangeLen)
rangeLow = ta.lowest(low, rangeLen)
plot(rangeHigh, "Range High", color=color.new(color.orange, 30), style=plot.style_circles)
plot(rangeLow, "Range Low", color=color.new(color.teal, 30), style=plot.style_circles)

// --- Swing High / Swing Low pivots (stop clusters) ---
swingHigh = ta.pivothigh(high, pivotLen, pivotLen)
swingLow = ta.pivotlow(low, pivotLen, pivotLen)

if not na(swingHigh)
    line.new(bar_index - pivotLen, swingHigh, bar_index + 30, swingHigh,
         color=color.new(color.red, 50), style=line.style_dashed)
if not na(swingLow)
    line.new(bar_index - pivotLen, swingLow, bar_index + 30, swingLow,
         color=color.new(color.green, 50), style=line.style_dashed)