OPEN-SOURCE SCRIPT

Reversal Pro | jjart

269
Reversal Pro hunts liquidity-sweep reversals and lets a machine-learning model decide which sweeps are worth acting on. The model is trained directly on your chart — on the exact symbol and timeframe you run it on — and retrains on a schedule as new bars arrive, so its scoring adapts to the instrument's current behavior instead of relying on fixed thresholds.

HOW IT WORKS

Trigger — pivot sweep. A candle takes out the lowest low (for longs) or highest high (for shorts) of the previous 8 bars and closes back in the opposite half of its own range — the classic stop-hunt / liquidity-sweep reversal footprint. Only these bars are candidates; the ML never fires in the middle of nowhere.
Features. Four context features are computed on the closed bar: RSI(14), relative volume (vs its 20-bar average), price Z-score over 20 bars, and ADX(14).
Models. Two independent model pairs — one for longs, one for shorts — each consisting of a classifier and a regressor built with the open-source Arbor gradient-boosting library by GainzAlgo:
the classifier's training target is "did price move at least 1 ATR in the trade direction within the next 15 bars?" — its output is the probability you see on the signal label;
the regressor's target is the actual forward excursion in ATR units — it drives the far take-profit (TP3). Models retrain every 75 bars on the last 500 bars (both configurable). Features are paired strictly with outcomes of already-closed forward windows, so training uses no lookahead.
Filters. A signal fires only when ALL of these pass: model score ≥ threshold (80% by default); the chosen direction's score exceeds the opposite one by a minimum edge (rejects "both sides look good" noise); ADX is inside the 12–38 regime window (no dead chop, no runaway trend); a cooldown has passed since the last signal. Optional extra filters (all OFF by default): CCI confirmation — a long requires a recent oversold CCI (≤ −100 within the last 3 bars), a short requires overbought; EMA trend filter — "with trend" takes longs only above the EMA(200) and shorts below it (pullback reversals), "counter-trend" does the opposite (fading stretched price back to the EMA); relative-volume floor — the signal bar's volume must be at least N× its 20-bar average.
No repaint. Signals are confirmed on bar close only — a printed mark never moves or disappears. Target/stop hits are evaluated on confirmed bars as well.
RISK MODULE

Stop-loss is anchored behind the signal bar's wick (the sweep extreme) plus a small ATR buffer; a minimum stop distance of 0.5 ATR is enforced.
TP1 = 1R (a true 1:1 to the initial risk, configurable). When TP1 is touched, the stop moves to entry (break-even, optional).
TP3 = the regressor's predicted excursion × ATR, floored at 2R so it never prints an unreasonably close target. TP2 = halfway between TP1 and TP3.
Level lines recolor as they fill; the trade completes at TP3 or at the stop. A stop hit after the break-even move is reported as a break-even exit, not a loss.
CHART OBJECTS & DASHBOARD

▲/▼ marks at the signal bar show the exact model score (e.g. 84.3%); 90%+ signals use the highlight color; the tooltip shows score, directional edge, ADX, RSI, CCI and the expected TP3 distance in R at signal time. The signal bar's background is softly tinted, and the Entry/SL/TP lines carry small price tags. Language: input names are bilingual (Russian / English); everything drawn on the chart — dashboard, statuses, level tags, tooltips — switches between English and Russian via the "🌐 Язык / Chart language" input. The dashboard shows: BIAS (higher-scored direction), GRADE (TRADE 80+ / WATCH 70-79 / NO EDGE) with the long-vs-short EDGE gap, LONG/SHORT scores, ADX vs its allowed window, RSI/RelVol, FEATURES (the model's live feature-importance split), FILTER status (READY / COOLDOWN / OFF-REGIME / TRAINING / IN TRADE), and STATS — live outcome statistics of completed signals on the chart (% reaching TP1 and TP3, % stopped out, % break-even).

HOW TO USE

Add to a liquid symbol; intraday timeframes 5m–1H work best. Let the model load history — the dashboard shows TRAINING until it has ~500 bars, then READY.
Wait for a ▲/▼ mark with the score. Entry reference is the close of the signal bar; SL/TP levels are drawn automatically.
Alerts are available for long/short entries, TP1/TP2/TP3, stop-loss and break-even exit.
Presets: 🕊 Relaxed (more signals) — score 0.70–0.75, edge 0.03–0.05, cooldown 5, ADX 10–45; 🔒 Strict (fewer, cleaner) — score 0.85–0.90, edge 0.10–0.15, cooldown 15–20, ADX 15–35. Every input's tooltip carries both recommendations.
WHAT IS ORIGINAL HERE / OPEN-SOURCE REUSE

The Arbor gradient-boosting library © GainzAlgo (MPL 2.0) provides the raw fit/predict algorithm and is credited in the code header. Everything trading-related is original: the pivot-sweep trigger gating the ML, the ATR-normalized forward-excursion labels and leak-free feature/label pairing, dual long/short model pairs with the directional edge filter, the ADX regime window, the bar-close no-repaint policy, the wick-anchored risk ladder with the model-driven TP3, break-even handling separated from stop-losses, the live hit-rate statistics, and the dashboard/labels/alerts layer.

DISCLAIMER

This is an analysis tool, not financial advice. Past performance of signals does not guarantee future results. Always manage your risk.

Описание — RU
Reversal Pro — разворотный индикатор, в котором каждый пивот-свип оценивается моделью машинного обучения, обучающейся прямо на вашем графике (конкретный инструмент и таймфрейм) и регулярно переобучающейся под текущий характер рынка.

Как рождается сигнал: (1) бар снимает 8-барный экстремум и закрывается в противоположной половине диапазона — классический вынос ликвидности; (2) модель оценивает контекст по 4 признакам: RSI(14), относительный объём, Z-score цены, ADX; для лонга и шорта — отдельные пары «классификатор + регрессор» (библиотека Arbor © GainzAlgo); таргет классификатора — «прошла ли цена ≥1 ATR в сторону сделки за следующие 15 баров», таргет регрессора — фактический ход в ATR; переобучение каждые 75 баров на последних 500, без заглядывания в будущее; (3) фильтры: скор ≥80%, перевес над противоположным направлением, ADX в окне 12–38, пауза между сигналами; опциональные доп. фильтры (по умолчанию выкл): подтверждение CCI (перепроданность/перекупленность рядом с сигналом), трендовый фильтр EMA (по тренду / контртренд), минимальный относительный объём сигнального бара; (4) подтверждение только на закрытии бара — без перерисовки.

Язык: названия настроек двуязычные (рус/англ), вся графика — таблица, статусы, ценники уровней, подсказки — переключается тумблером «🌐 Язык / Chart language».

Риск-модуль: SL за фитилём сигнального бара + запас ×ATR (минимум 0.5 ATR); TP1 = 1R с переносом в безубыток; TP3 = прогноз регрессора с нижней планкой 2R; TP2 — середина. Стоп после переноса в БУ считается безубытком, а не лоссом.

На графике: метки ▲/▼ с точным скором (90%+ подсвечиваются), линии Entry/SL/TP с перекраской при достижении, дашборд (скоры, BIAS/EDGE/GRADE, режим ADX, важность признаков, статус движка, живая статистика отработки TP1/TP3/SL/BE) и алерты на все события.

Пресеты: 🕊 мягкий (больше сигналов) — скор 0.70–0.75, перевес 0.03–0.05, пауза 5, ADX 10–45; 🔒 строгий — скор 0.85–0.90, перевес 0.10–0.15, пауза 15–20, ADX 15–35.

Дисклеймер: инструмент анализа, не финансовая рекомендация. Управляйте риском.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน