Gap Share of True Range
True range holds two parts, the distance price covered inside the bar and the jump from the prior close to the bar. It is hard to tell from one number which part dominated. This script puts the gap part of true range, as a percent of true range, in a pane for every bar.

What it shows
- Columns for each bar: the gap part divided by true range, from 0 to 100 percent. Columns at or above the high share level are orange. Other columns are blue.
- A pink line with the average of that share over the chosen number of bars.
- A dashed line at the high share level and a dotted line at zero.
- Two data window values, the average gap part and the average bar range part, both in price units. They show in the data window only.
- A table in the top right corner with the window length, how many bars in the window had any gap part, how many bars sat at or above the high share level, and the current average share.
How it works
True range is the distance from the lowest of the low and the prior close to the highest of the high and the prior close. The bar's own range is high minus low. The gap part is true range minus the bar's own range, never below zero. It is the extra distance that exists only because the bar opened away from the prior close and did not trade back through it. The share is the gap part divided by true range, times 100. A bar with no gap part shows zero. The first bar of the chart has no prior close and is skipped.
The average is a simple average of the per bar share over the average length. If you turn on the range weighted average, the line is the sum of gap parts divided by the sum of true ranges over the same bars. Wide bars then count more than quiet ones.
How to use it
- Add it to a daily chart of a stock, an index or a futures contract. Other timeframes work, but gaps appear mostly between sessions.
- Read the columns to see which bars were mostly a gap and which were mostly movement inside the bar.
- Compare the pink line with the columns to see whether the recent share is above or below its own average.
- Change the average length, the high share level and the weighting in the settings to fit the symbol.
Why it is different
This script splits true range into the gap part and the bar range part with an exact identity, so the two parts always add back to true range. The range weighted option gives a second view of the average, based on total distance instead of bar count.
Limits
- Inputs and defaults: Average length 20, Range weighted average off, High share level 50 percent, Show gap and bar range averages on, Show summary table on.
- Markets that trade around the clock without a gap, such as most crypto pairs, will show shares near zero.
- On an intraday chart of a continuous market, the gap part is the jump from one bar to the next and is usually small.
- The current bar changes until it closes, so its column can move while it forms.
- A gap that trades back through the prior close inside the same bar shows a gap part of zero, because the bar's own range already covers it.
- The first bar has no prior close and is left out. The average line starts once the window holds the chosen number of bars after that.
- It draws on the chart only. It places no orders and is not advice about any trade.