ITMScript
Track the session high
Draw the highest high of the current session and restart it on the first bar of each session with scan.
Carry the highest high of the current session and start again on the first bar of the next one.
//@itmscript 2
study("Session high", overlay=true)
edge = input.color(color.green, "Line")
highest(acc, x) => math.max(nz(acc, x), x)
sessionHigh = scan(high, na, highest, reset=session)
top = plot(sessionHigh, "Session high", color=edge, width=2, style=stepline)
last = plot(close, "Close", color=color.gray, width=1, style=line)
fill(top, last, color=color.new(color.green, 92))What you see
A stepped line over the candles shows the highest high so far in the session. It restarts at the first bar of each session. The space between the line and the close is lightly filled, so the size of the pullback from the high is easy to see.
reset=session returns the carried value to its start on the first bar of each trading day. On a daily or coarser chart there are no sessions to tell apart, so the line is the highest high since the first bar.
Change these inputs
- Line. The colour of the session high line.