OPEN-SOURCE SCRIPT
Updated

Support Resistance AI [PickMyTrade]

8 578
Every support/resistance tool answers "where are the levels." None answer the question a trader actually has when price arrives at one: does THIS test look like the ones that held, or like the ones that broke?

――――――――――――――――――――――――――――――――――――――
snapshot

🔷 WHAT IT MEASURES
🔸 Confirmed swing pivots, clustered into zones and merged as new evidence accumulates
🔸 Eight properties of every ARRIVAL at a zone — approach speed, relative volume, prior test count, zone age, trend pressure, zone width, pivot count, and cumulative touches
🔸 A broken level isn't discarded — it flips role once (broken support becomes candidate resistance) and only a second failure retires it
🔸 A live Previous Day/Week High/Low reference map, shown only when price is within range

――――――――――――――――――――――――――――――――――――――

🔷 THE CLASSIFIER
🔸 An online Gaussian Naive Bayes model, trained continuously as tests resolve — no repainting, no lookahead
🔸 Nothing about a level's price is used as a feature — only how price approached it
🔸 The classic claim that "a level tested repeatedly grows weaker" is measured on each chart's own history here, rather than assumed
🔸 Below a configurable warmup sample count, the script shows the chart's running hold rate instead and reads LEARNING — it never guesses early

――――――――――――――――――――――――――――――――――――――

🔷 SIGNALS AND DISPLAY
🔸 Zone boxes colored by role (support/resistance) and shaded by live conviction, with worded verdicts ("similar arrivals held X%") instead of a bare number
🔸 Rank-based visibility — only the nearest zones to current price are drawn, so old or distant levels never stretch the chart's scale
🔸 Test history ticks stamped inside each zone at the bar where its own tests resolved
🔸 An info table with Nearest Support/Resistance, model accuracy, and sample counts
🔸 3 alertconditions, worded as observations of what the classifier's reading — never as trade instructions

――――――――――――――――――――――――――――――――――――――

🔷 INPUTS
Pivot Left/Right Bars — swing detection window. Default 10/10.
Zone Width / Merge Distance — band thickness and clustering tolerance, in ATR. Default 0.5 / 0.75.
Break Buffer / Rejection Distance — how far price must close beyond or travel back from a zone to resolve a test. Default 0.25 / 0.75 ATR.
Post-Flip Cooldown — bars a flipped zone must survive before a break can retire it. Default 5.
Warmup Samples — resolved tests required before the classifier is trusted. Default 25.
Conviction Threshold — probability at which a zone is shown at full conviction. Default 0.62.
Max Live Zones / Show Distance — how many nearby zones are drawn and how far (in ATR) before one is hidden.
Show Trend EMA, Zen Mode — display toggles; Zen Mode hides labels and the table for clean screenshots.

――――――――――――――――――――――――――――――――――――――

🔷 REQUIREMENTS AND LIMITATIONS
🔸 Pivots confirm only after the right-side lookback bars close — a level appears on the chart later than the swing that created it, by design
🔸 One thing does refine retroactively: when a later pivot merges into an existing zone, its band re-centers toward the weighted average — a zone with an open test is never re-centered, so no in-progress outcome is affected
🔸 Early on a fresh chart, or for a zone with only one or two tests, its own read is thin — the model's overall sample count travels with every verdict so that's never hidden
🔸 This script reports how historical arrivals resolved. It does not predict, and it is not a trading system on its own.

――――――――――――――――――――――――――――――――――――――

Built in Pine Script v6. Open source — Mozilla Public License 2.0.
Release Notes
🔷 WHAT'S UPDATED IN V2
🔸 Every level now carries an A–D evidence grade, so the strength of a level can be read at a glance
🔸 Label size, HTF tag size, zone border width and HTF line width are all adjustable — the levels can be made as easy to see as the chart needs
🔸 Higher-timeframe tags sitting close together no longer print on top of each other
🔸 No colour has been changed — at default settings V2 renders exactly as V1 did

――――――――――――――――――――――――――――――――――――――

🔷 LEVEL EVIDENCE GRADE (A–D)
🔸 Stamped in each zone's corner and repeated on its worded label — top corner for resistance, bottom for support, so it sits on the side price approaches from
🔸 Measures how much history stands behind the LEVEL: merged pivots 35%, touches 25%, resolved tests 20%, age 20% (log-damped)
🔸 A 75+ · B 55+ · C 35+ · D below 35
🔸 Deliberately separate from the hold percentage — the grade says how much evidence a level has accumulated, the percentage says how similar arrivals resolved. A thin new level can sit where arrivals historically held; a heavily tested one can be where they keep breaking. Folding them into one number would hide exactly the disagreement worth seeing
🔸 A role flip resets tests and age, so a flipped level regrades from its new role's own record
🔸 Grades re-read as evidence accumulates — toggle it off if you prefer the V1 look

――――――――――――――――――――――――――――――――――――――

🔷 VISIBILITY CONTROLS
🔸 Label Size — Tiny / Small / Normal / Large / Huge, for the worded Support and Resistance labels (default Small, V1's size)
🔸 HTF Tag Size — Tiny / Small / Normal / Large, for the PDH / PDL / PWH / PWL / PMH / PML price tags (default Tiny, V1's size)
🔸 Zone Border Width — 1 to 4. Zones built from 3 or more merged pivots still draw one step heavier than the base, and the test-history ticks scale with it
🔸 HTF Line Width — 1 to 3, for the dotted previous-period lines
🔸 The HTF tags mattered most here: they were the smallest text in the script and were previously fixed with no way to change them, which is much of why levels were hard to read. They now have their own control, independent of the zone labels
🔸 Two higher-timeframe levels a fraction of an ATR apart used to stack their tags into a smear — larger text made that worse. The redundant tag now stands down within 0.30 ATR. Both LINES still draw; only the duplicate label yields, and the higher timeframe keeps it
🔸 Nothing was restyled. Making levels easier to see is a size and thickness problem, not a palette problem — support is the same blue, at the same transparency, on the same label backing

――――――――――――――――――――――――――――――――――――――

🔷 WHAT HASN'T CHANGED
🔸 The classifier and its eight arrival features, training and warmup rules
🔸 Zone clustering, merging and re-centring
🔸 Test resolution, the role-flip rule and retirement
🔸 The non-repainting discipline — still no security() call, still confirmed bars only
🔸 The higher-timeframe map, the info table and every alert condition

V2 adds two features and changes nothing underneath them.

――――――――――――――――――――――――――――――――――――――

Both updates came from suggestions in the comments. More are welcome.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.