Video Walkthrough

0.85% Liquidation Ladder (Manual Anchor) — Pine v6

//@version=6
indicator("0.85% Liquidation Ladder (Manual Anchor)", overlay=true, max_lines_count=500, max_labels_count=500)

//─────────────────────────────
// Inputs
//─────────────────────────────
anchorPrice     = input.float(1.0,  "Anchor Price (0%)", step=0.0001)
stepPctIn       = input.float(0.85, "Step (%)", step=0.01, minval=0.0001)
levelsDown      = input.int(20,     "Levels Down", minval=1, maxval=200)
showLabels      = input.bool(true,  "Show % Labels")
lineWidth       = input.int(1,      "Line Width", minval=1, maxval=5)
labelOffsetBars = input.int(50,     "Label Offset (bars to right)", minval=1, maxval=300)

showMidLines    = input.bool(true,  "Show 0.42% Mid Lines (dashed)")

//─────────────────────────────
// Persistent storage
//─────────────────────────────
var line[]  lvLines   = array.new_line()
var label[] lvLabels  = array.new_label()

step = stepPctIn / 100.0

f_clear() =>
    while array.size(lvLines) > 0
        line.delete(array.pop(lvLines))
    while array.size(lvLabels) > 0
        label.delete(array.pop(lvLabels))

f_pctText(n) =>
    n == 0 ? "0%" : str.tostring(stepPctIn * n, "#.##") + "%"

//─────────────────────────────
// Draw ladder (refresh on last bar only)
//─────────────────────────────
if barstate.islast
    f_clear()

    for n = 0 to levelsDown
        lvl = anchorPrice * (1.0 - step * n)

        ln = line.new(
            bar_index - 1, lvl,
            bar_index,     lvl,
            extend = extend.both,
            width  = lineWidth,
            color  = color.gray,
            style  = line.style_solid
        )
        array.push(lvLines, ln)

        if showLabels
            lb = label.new(
                bar_index + labelOffsetBars, lvl, f_pctText(n),
                style     = label.style_label_left,
                textcolor = color.white,
                color     = color.new(color.black, 0)
            )
            array.push(lvLabels, lb)

    if showMidLines
        for n = 0 to (levelsDown - 1)
            midLvl = anchorPrice * (1.0 - step * (n + 0.5))

            midLn = line.new(
                bar_index - 1, midLvl,
                bar_index,     midLvl,
                extend = extend.both,
                width  = 1,
                color  = color.gray,
                style  = line.style_dashed
            )
            array.push(lvLines, midLn)

Need help or want more scripts?

Ask in the community and grab updates.

Join the Discord