Skip to content

hl2 - PineScript Variable

hl2 is a shorthand for (high + low) / 2. It provides the midpoint of the bar’s range and is often used as a smoother input compared to raw closes.

float

series

  • Unlike close, hl2 softens intrabar noise by averaging extremes.
  • Because it depends on high/low, hl2 updates intra-bar whenever a new extreme is made, then locks at bar close.
  • Works well as a source input to moving averages or oscillators when you want a blend of high/low information.
//@version=5
indicator("HL2 vs Close", overlay=false)
plot(close, "Close", color=color.blue)
plot(hl2, "HL2 midpoint", color=color.orange)
spread = close - hl2
plot(spread, "Close - HL2", color=color.new(color.purple, 0), display=display.none)