OPEN-SOURCE SCRIPT

Filter Reality Check

573
# Filter Reality Check — does your condition actually select anything?

My last script measured what entering at random would have produced on a
chart at a given reward-to-risk. The question everybody asked next was the
obvious one: *fine — does my filter beat that?*

Almost nobody measures it. This does.

It resolves every bar in the sample exactly once, then counts the outcome
twice: into the baseline, and into the filtered set if your condition was
true on that bar. Same bars, same distances, same resolutions — so the
difference between the two rates is the filter and nothing else.

## What the table shows

**All bars.** The baseline. What entering at random would have produced
here at your reward-to-risk.

**When condition true.** The same measurement, restricted to bars where
your filter passed.

**The filter is worth.** The difference, in percentage points of hit rate.
This is the number you came for.

**Bars it kept.** What share of the sample survived the condition. This
matters more than it looks: a filter true on 97% of bars is not selecting
anything, and its hit rate will match the baseline for that reason alone.
If this figure is near 100%, the filter is decoration.

**Filtered vs break-even.** Whether the filtered rate clears what your
reward-to-risk actually demands, after costs.

## Conditions you can test

Price above or below a moving average (EMA or SMA, any length), ADX above
a level, RSI above or below a level, volatility rising (ATR above its own
average), volume above a multiple of average, inside a session window, or
**any custom source above a level** — which lets you point it at another
indicator on your chart and test that.

## What you should expect to find

Most filters are worth nothing.

That is the finding, not a failure of the tool. A condition that moves the
hit rate by half a point is a condition you can delete, and knowing which
of yours those are is worth more than adding another indicator. The script
says so plainly when it happens.

Occasionally you will find one that costs you points — where you would
genuinely do better entering at random. Those are worth knowing about
before they are load-bearing in a strategy.

## Method, and its limits

**The condition is read on the entry bar itself**, using only data that
existed then. A filter evaluated with information that arrived later would
flatter itself and the result would be worthless.

**A bar spanning both stop and target counts as a loss.** There is no way
to know which came first from bar data, and being wrong pessimistically is
the only honest way to resolve it.

**Samples that reach neither level within the holding window are reported
as timed out**, not quietly dropped.

**Distances can scale with each historical bar's own ATR**, so the test
uses the volatility of the time rather than today's.

**The table states the period covered.** Six hundred bars is two days on a
5m chart and two years on a daily one, and a percentage with no period
attached invites more confidence than it has earned.

**Thirty resolved samples is the floor.** Below that the script refuses to
draw a conclusion, and it will tell you when your condition was true too
rarely to judge — which happens often with tight filters on short samples.

## What it is not

It places no trades, gives no signals and predicts nothing. It measures
what a condition would have selected on the history in front of you, on
this instrument, over this window. Run it across several windows before
you believe any single number, and check whether the direction you are
testing happened to be the way the market was going.

A filter that improves the hit rate may still be worthless for other
reasons — overfitting, costs, or a sample too small to mean anything.
This measures one thing and only claims that one thing.

Open source. Companion to *Edge Reality Check*, which measures the
baseline this compares against.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.