OPEN-SOURCE SCRIPT

Rarity Tint [BSL]

210
Almost every indicator uses colour to tell you something it believes. This one
uses colour to tell you how much it knows.

Rarity Tint [BSL] shades the chart background by a single number: how many
earlier bars were in the same market state as the current one. A state the
market has been in hundreds of times is almost clear glass. A state seen twice
before is nearly opaque. A small panel prints the count and the total it was
drawn from, so the shading always has a number standing behind it.

ONE SUBSTITUTION, AND THAT IS THE WHOLE PRODUCT

The usual arrangement puts a claim in the colour and the sample size in a
footnote, if it appears at all. Here the colour IS the sample size. You cannot
look at the shading without also seeing how much evidence it rests on, because
they are the same thing.

There is nothing in the footnote, because there is no claim.

READING THE SHADE

Darker means rarer. The scale saturates: once a state has occurred as many
times as the saturation setting, the tint stops changing, so a state seen 400
times does not look different from one seen 40. Both are common; the
distinction between them is not worth a visual difference.

The count uses bars strictly BEFORE the current one. The bar being described
is never part of its own evidence.

Nothing is shaded until the minimum number of bars has been counted. A rarity
reading taken over 30 bars is a statement about those 30 bars, not about the
market, and showing it would be worse than showing nothing. Until the minimum
is reached the panel says how many bars it has and why there is no tint yet.

There is a second reason the chart can come up blank, and the panel names that
one too. If the current state has occurred more times than the saturation
setting, the shading is fully transparent by design, and on a long chart that
is true of nearly every state. The panel then reads SATURATION 40 · STATE SEEN
MORE OFTEN · NO TINT · RAISE SATURATION TO SEE ONE. A blank chart is a real
answer here, so the product says which answer it is rather than leaving you to
guess whether it is broken.

The bar still forming is marked with the word FORMING rather than a count that
the next tick could change. Beside it the panel prints the count of the last
CLOSED bar, so the number the shading stands for is visible while you are
watching a live chart.

WHAT A STATE IS HERE

A state is a cell built from three axes. By default the script computes its
own: how far the close sits from a 50-period EMA, the ATR, and volume, each
ranked over a rolling window so the cell means the same thing on any
instrument.

You can replace all three. Turn the built-in axes off and each one comes from
an indicator you connect through the Source setting, the same dropdown
TradingView uses everywhere for picking a series.

Two consequences are worth knowing before you do it. The Source dropdown
reaches only indicators ALREADY LOADED on the chart. It cannot see one you
have not added. And changing any axis redefines every cell, so the entire
history is recounted rather than adjusted. The numbers you were reading a
moment ago do not carry over.

The built-in axes sit behind a switch for an honest reason: TradingView only
allows a connectable input to default to a built-in price series, so none of
the three declared defaults could be offered as a default connection. The
switch is how they are delivered without pretending otherwise.

HOW FAR BACK THE COUNTING GOES

As far as the chart has loaded, and no further. A chart showing 5,000 bars
counts over 5,000 bars; scroll back and the counts grow. Nothing is stored
between sessions. The counters are rebuilt from the loaded history each time
the script runs. Two people looking at the same symbol can see different
numbers and both be right, and the panel prints the total so the difference is
never hidden.

THE SETTINGS

- Use the built-in three axes: on
- Built-in axis 1, EMA length: 50
- Built-in axis 2, ATR length: 14
- Rank window: 100 bars
- Minimum counted bars before any tint: 300
- Occurrences at full transparency: 40
- Panel position: Bottom center

The panel can go in any of six places. It starts at the bottom center: clear of
the price scale, clear of the other scripts in this catalogue, which keep to the
right, and clear of the legend and the logo, which hold the two left corners.

WHY IT STOPS ON HEIKIN ASHI AND RENKO

Ranking requires the values being ranked to be comparable to each other. On
Heikin Ashi, Renko, Kagi, Point & Figure and Range charts the bars are built
from the market rather than taken from it, so a state computed there describes
the construction. Counting how often a constructed state occurred is counting
something that never traded.

On those chart types the tint, the counters and the published values switch
off and the panel shows one frozen warning naming the chart type.

PUBLISHED FOR OTHER SCRIPTS

Two values are published for other indicators to pick up in their Source
setting.

The first is the cell the bar fell into. It is a NAME written as a number:
cell 7 is not larger than cell 3, and averaging these would produce nothing.

The second is the occurrence count: how many earlier bars shared that cell.

Both carry no value at all before the script has an opinion, which is
different from a count of zero. No value means "nothing measured yet". Zero
means "measured, and this state had never occurred".

The script's alert condition is listed in the same dropdown. It is not a value
and there is nothing useful to read from it. The two named here are what the
script publishes.

WHAT IT WILL NOT TELL YOU

It never says what a rare state implies. It measures how much evidence exists
and stops.

It does not name the state: cell 7 is a code, not "compression" or "trend",
because naming it would smuggle in a meaning the count does not support. It
does not suggest that rare is dangerous, tradeable or interesting. It reports
no outcome of any kind: adding what happened next would turn an evidence meter
into a prediction, which is a different product with different obligations.

Which historical bars were the nearest matches, and what followed them, is
that different product, where the distance measure and the neighbour count
have to be disclosed.

This tool describes how often a state has occurred. It does not predict price,
guarantee performance or provide trading advice. Validate the behaviour on
your own symbols, timeframes and execution assumptions before making
decisions.

Open-source Pine Script® v6. Educational use only.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.