indicator · on price · open source

Internal Structure

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Internal Structure plots the swing pivots and stair-step structure line of the current timeframe only. (HTF overlay is parked until request.security() is available in the runtime.)

  • Plot shows HH/LH/HL/LL classification of every confirmed pivot.
  • Use on lower timeframes to read the micro-structure inside a higher-TF range.
  • Combine with the premium / discount indicator for cleaner entries.

Source code

//@version=5
indicator("Internal Structure", overlay=true)
swing = input.int(5, "Swing Length", minval=2, maxval=50)
ph = ta.pivothigh(high, swing, swing)
pl = ta.pivotlow(low, swing, swing)
var float lastPh = na
var float prevPh = na
var float lastPl = na
var float prevPl = na
var string hiLab = ''
var string loLab = ''
if not na(ph)
    prevPh := lastPh
    lastPh := ph
    if not na(prevPh)
        hiLab := ph > prevPh ? 'HH' : 'LH'
if not na(pl)
    prevPl := lastPl
    lastPl := pl
    if not na(prevPl)
        loLab := pl > prevPl ? 'HL' : 'LL'
hiLine = ta.valuewhen(not na(ph), ph, 0)
loLine = ta.valuewhen(not na(pl), pl, 0)
p_Internal_Hi = plot(hiLine, "Internal Hi", color=color.blue, style=plot.style_stepline, linewidth=2)
p_Internal_Lo = plot(loLine, "Internal Lo", color=color.purple, style=plot.style_stepline, linewidth=2)
plotshape(not na(ph) and hiLab != '', "Hi Label", style=shape.labeldown, location=location.abovebar, color=color.blue, text="hiLab")
plotshape(not na(pl) and loLab != '', "Lo Label", style=shape.labelup, location=location.belowbar, color=color.purple, text="loLab")

Comments

No comments yet.

Sign in to comment.