OPEN-SOURCE SCRIPT
Aktualisiert Highest/Lowest value since X time ago, various indicators

This script will count the bars back since the last time the current bar indicator value was either this low or this high.
It will provide the time in either, seconds, minutes, hours, days, weeks, months, or years.
please note:
There are currently no alerts setup for this script.
the length options only apply to the sources that have the "(MA)" in their name.
There is a horizontal line display issue which corrects once you adjust the amount of sources you want to use.
Once you select the amount of sources you would like to use, align the indicator so the horizontal lines match up with the table lines.
If find any bugs in the script, let me know.
It will provide the time in either, seconds, minutes, hours, days, weeks, months, or years.
please note:
There are currently no alerts setup for this script.
the length options only apply to the sources that have the "(MA)" in their name.
There is a horizontal line display issue which corrects once you adjust the amount of sources you want to use.
Once you select the amount of sources you would like to use, align the indicator so the horizontal lines match up with the table lines.
If find any bugs in the script, let me know.
Versionshinweise
The script compares the current bar’s value based off the source selected to the historical bars. If the bar is a low value, it will look back and count until it finds another bar with a lower value. It will then convert the bars counted in to a one decimal place numerical value followed by a suffix. It will do the same for the high values.So for an example, if you select source 1 as the RSI on the 15 minute chart. If the value of the relative strength index (RSI) is low, let’s say 10 – it will count how many 15-minute bars back until it finds an RSI value lower than 10. It then adds up all the bars and generates a label with the duration of time since a value was less.
There is one decimal place for everything else other than the seconds.
So, if the “bars time ago” was 1 day and 12 hours, it will show as 1.5d
The indicator will not count bars back further than what is specified in the count bars back limit option. So, if you select 60 bars on the 1 minute chart, the most it will look back will be to 60 bars ago which happens to be 1hr.
The indicator name distance is an integer value. With higher numbers, the source label name will move further away from the chart’s counted time labels.
The display filter option will only provide labels if the amount of time is greater than what is specified in the labels higher than option with the dropdown of time settings.
The time dropdown menu of seconds, minutes, hours, days, weeks, months, years.
The “display sources” menu will display the amount of sources/indicators you’d like to use. The length value on each source only applies to sources that have the moving average “(MA)” in their name.
The
please note:
There are currently no alerts setup for this script.
the length options only apply to the sources that have the "(MA)" in their name.
Display sources is the number of sources you’d like to have for labels. The horizontal lines between the sources will only display correctly once the display sources is changed.
The ease of movement source (eom) does not use the box ratio in its calculation and instead is simply the volume divided by the price move.
“The lowest since x time ago color” is the color for the labels that are the lowest since a certain amount of time ago.
“The highest since x time ago color” is the color for the labels that are the highest since a certain amount of time ago.
Currently the script has the follow indicators/values as sources:
ATR: Average True Range
CCI: Commodity Channel Index
COG: Center of Gravity
Close: Closing Price
Close percent: Percentage change in closing price
Dollar value: Total value of shares traded in dollars
EOM: Ease of Movement
Gaps: Price gaps between trading periods
High: Highest price of a trading period
Low: Lowest price of a trading period
MFI: Money Flow Index
OBV: On-Balance Volume
Open: Opening price of a trading period
Range Moving Average: Moving average difference between high and low prices of a trading period
RSI: Relative Strength Index
RVI: Relative Volatility Index
TimeClose: Closing time of a trading period
Volume: Total number of shares traded
Volume (MA): Moving average of trading volume
There are many ways you can use this script. The main idea is to pick up on sudden changes. An example could be if the range moving average has been the lowest since a long time ago, however the money flow shows highest since x time ago, and then is accompanied by highest volume since x time ago etc.
The lowest low since years ago with a highest close since years ago might be the start of an uptrend.
You can mix each source to get a better understanding of your strategy.
Versionshinweise
corrected text size for the source label names.Versionshinweise
The Range MA is updated to only use an absolute percent value (positive number). The range MA looks at the past length of bars and compares the percent value from the lowest bar to the highest. If the current value is less than the previous bar’s value, it will then start counting back until it finds a lower value than itself and will provide you the amount of time since the occurrence.Example:
So if you set the moving average range length to 20 bars, in those 20 bars the highest high compared to the lowest low is only 5%. If the previous bar’s moving average range was 8%, it will then keep counting back until it finds a bar that is less than the current bar of 5%. Then the value will be presented as a red label with a time of how long ago the first occurrence happened.
The highest value since x time ago works the same but in reverse. So, if the current bar’s value instead was 10%, and the previous bar’s value was 8%, it will count back until it finds a value higher than the 10%. It will then give you a label in green with the time lapsed since the first occurrence.
Versionshinweise
The entire script has been re-written to add more features.Below is a description of how this updated indicator works.
For simplicity we'll be on the daily timeframe and assume there is only 100 candles being displayed with one source selected as the RSI MA1 (moving average). The MA1 (moving average length) is set to 14 days.
Each block represents the percent rank of the candle's RSI value compared to all previous candles.
An example of how it is calculated:
Let's say the current candle's RSI is extremely low at 8, it will then compare its value to the prior candle. If the current candle's RSI is lower than the previous, it will count how many previous candles there were until it finds a value less than 8. If 99 candles were counted, then this means there were 99 counted candles until a value below 8 was found.
This 99 value is assigned to the current colored block. To get the color for this block, It is positioned within a percent rank with all other blocks that recorded their current candle's RSI lower than previous candles' RSI. Since there were only 100 candles and this one was lower than 99 prior candles, it will belong to the color group, "percent rank colors low to lower" 91 to 100 percent rank (currently set to bright pink/purple. If however the current candle's RSI only was lower than one previous candle, it'd have belonged in to 0 to 10 percent rank (dark red color).
The same principle is applied when dealing with the candle's RSI that is higher than previous RSIs. The only difference is, if the current candle's RSI is higher than 99 prior candles, it will be compared with all other blocks that had stored values of where a their candle's RSI was higher than previous candle RSIs. The color will then be assigned to the color group "percent rank colors high to higher" and will be placed in the 91 to 100 percent rank (bright teal color).
The formula for the timeframe length of candles is as follows:
99 counted candles are converted in to seconds then divided by the seconds in a month.
86,400 seconds in one day * 99 daily counted daily candle = 8,553,600 total seconds.
8,553,600 total seconds divided by 2,628,003 seconds in a month = 3.3M (M for month) since a prior candle was found that had a lower RSI.
This indicator's options are:
Sources - the amount of sources to display, minimum is 1 and maximum is 10 (note: having 10 sources creates a longer script load time. Trading view will not load scripts that are longer than their maximum load time limit.)
Load from the beginning / load from x bars - choose whether to load the blocks from the beginning of the chart or from the past amount of bars.
x bars: - the amount of prior bars of when the indicator should load.
Color based on (all bars)/(x bars:) - All bars will look at all prior candles for when calculating higher or lower prior candles and the percent rank color it will receive. X bars will only look at past amount of candles you enter.
x bars: - amount of prior bars to consider when calculating percent rank colors and time since prior low or high. This value only works if you have set color based on (all bars)/(x bars:) to "x bars:".
block vertical height trim - controls the vertical height of the blocks. At 0 there is barely a vertical gap between blocks at 0.5 the blocks disappear. minimum value is at 0, max is at 0.5.
Sources
sources with "MA1" in their name use the moving average length MA1. Whether sources use the MA1 or not, you can apply an additional moving average with the MA+.
ATR MA1 - All true range
body distance - the upper body minus lower body of the candle (does not include the wicks).
CCI MA1 - commodity channel index.
close percent - current close percent difference from previous close.
close - close price.
COG MA1 - center of gravity.
dollar value - volume * ((high + low + close) / 3)
close distance over volume - percent difference from current close to previous close divided by volume.
gaps - current open minus previous close.
high - high price.
low - low price.
MFI MA1 - money flow index.
OBV - on-balance volume.
open - open price.
range MA1 - moving average of high minus moving average of low.
RSI MA1 - relative strength index.
RVI MA1 - relative vigor index.
volume MA1 - moving average volume.
volume - volume.
Percent rank colors low to lower and percent rank colors high to higher - choose the colors for each block that falls in the percentage ranges. For source values that are lower than previous lows, they will use the low to lower colors, while source values higher than previous ranges will use the high to higher.
show more labels on left - there is a limit to how many labels can be shown. Moving this slider to the left will display the block's counted time label. Moving it enough to the left starts to remove labels to the right in order to display prior labels.
show more labels on right - if you have increased "Source label slider" to move labels to the left, if you're on a higher trading view plan, you will have access to more labels to be displayed. You might be able to increase this value to expand the range of labels shown. If you increase it too much labels on the left will begin to be removed.
source name label size
source value label size
title label horizontal distance - controls the horizontal distance of title labels.
source label text color
source label text outline color
title label text color
title label text outline color
Versionshinweise
HIGHEST/LOWEST VALUE SINCE X TIME AGO 2.0 — how rare is this moment?Complete redesign. Up to EIGHT metrics, and for each one, every bar answers a simple question:
how far back do you have to go to find a value this LOW (or this HIGH)? The answer is drawn as
a colored streak-band and translated into HUMAN TIME:
"volume at its lowest in 3.2 months" · "RSI at its highest in 1.1 years"
— and into the ACTUAL DATE: each row can also show the candle the streak reaches back to,
"lowest: since 12 Mar 24" (label detail modes: span / date / both).
━━━ READING THE ROWS ━━━
Each metric is one horizontal band. Hue = which extreme is running (green family = at/near its
highest in a long time, red family = at/near its lowest — both colors yours). Brightness = how
RARE that streak is compared to this metric's own streak history — dim is ordinary, vivid is
exceptional. Each row's label reads: name · "lowest 3.2mo · 87%" · "since 27 Apr 26".
A "+" means the streak spans the entire history window — it is at least that old.
SPOTLIGHT MODE: one toggle finds the row holding the LONGEST streak right now, keeps it at full
color and dims every other row — one glance shows the record-holder (its label gets a ★).
BLOCK VISIBILITY: choose "always" (every bar colored, brightness = rarity) or "only at/above
the row threshold" — rows stay INVISIBLE until their streak rarity crosses that row's own
threshold; silence, then a block appears = something rare is happening.
Dates never disappear: a streak older than the whole window reads "before 12 Mar 24" (the
window edge) instead of dropping the date.
Color templates beyond the two-color default: Ice & fire and Diverging blue-red put rare LOWS
at the cold end and rare HIGHS at the hot end of one scale; Inferno / Viridis / Plasma /
Monochrome / Custom paint pure rarity heat (the label says which side). And inline tags print
the streak span ON EVERY BLOCK ("1.9mo" right on it — the classic face of this indicator), or
the row's name, or both. Interval, transparency, size, depth and vertical block gap are all
yours; two tag styles trade exact band placement against deeper tag history.
━━━ WHAT A ROW CAN TRACK ━━━
close · high · low · volume · dollar value · RSI · MFI · Stochastic %K · CCI · ROC % · ADX ·
true range % · ATR % · stdev volatility % · stretch from EMA50 % · body/range % · gap % ·
move per volume · plus TWO EXTERNAL slots — pipe in any other indicator's plot.
Classic uses: "lowest low since…" for support hunting, "highest volume since…" for climax
spotting, and the squeeze preset — when RANGE and BODY are at their lowest in months, a
breakout is loading.
━━━ PRESETS ━━━
Price extremes (low·high·close·volume) · Momentum extremes (RSI·CCI·Stoch·MFI) ·
Volume & flow · Volatility squeeze (ATR·range·body·gap — rare LOWS = compression) ·
User defined (8 rows: metric + length + rarity threshold).
━━━ PER-ROW THRESHOLDS + THE YARDSTICK ━━━
Every row has its own rarity threshold (the third box). It does two jobs: alerts fire when that
row's streak rarity ENTERS it, and the label can show what that percentile equals in time —
"rare ≥ 8.2d" tells you how long a streak must run on THIS chart before it counts as rare.
━━━ ALERTS ━━━
One alert ("Any alert() function call") when a row's streak ENTERS its own rarity threshold —
the message speaks plainly: "RSI at its HIGHEST in 3.2mo (since 12 Mar 24)".
━━━ UNDER THE HOOD / HONESTY ━━━
The streak search uses a skip-pointer walk (each bar memoizes its own streak so the search jumps
whole runs at once) — fast even with 8 rows on long charts. Streaks are measured against a
bounded history window you control, from CLOSED bars only; the forming bar's row color can shift
until it closes. Rarity is context, not a signal. Not financial advice.
Portions of this script were developed with AI assistance; all logic was reviewed and tested by me.
━━━ CHANGELOG (2.0) ━━━
• Fixed: the bounded-window mode never worked (an internal option-string typo made it dead code)
— history is now bounded by default, and memory no longer grows forever on long charts.
• Fixed: a rare streak mis-count on metrics with flat runs (equal values) combined with a trend
flip — the streak walk is now strict-comparison consistent, so ties cannot corrupt a jump.
• Added: alerts — the whole point of the tool is "tell me when something is rare", and now it
does, in plain language with the human-time span.
• Added: per-row rarity thresholds with a plain-time yardstick ("rare ≥ 8.2d"), actual DATES on
every row ("since 12 Mar 24" / "before …" past the window), block-visibility gating (rows can
stay invisible until rare), and a longest-streak spotlight mode.
• Added: presets, external source rows, streak rarity ranking (brightness), on-block span tags
with adjustable depth, label offset and full text-size range.
• Performance: labels update in place on the last bar instead of being recreated every bar;
unused rows do zero work.
• Changed: human-time labels now say "lowest 3.2mo" instead of a bare number (months are "mo" so
volume rows can't be misread as millions), with a bar-count fallback on non-time chart types.
Versionshinweise
Percent rank update.Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.