OPEN-SOURCE SCRIPT
Khusan Pullback & Mean-Reversion (Manual ADX, Clean)

Description
The indicator combines two logics in one tool:
Trend Pullback: Entries in the direction of the dominant trend after a short-term pullback to the EMA.
Return to the mean (Mean-Reversal): countertrend trades from external Bollinger bands with an RSI filter.
Key Features
Manual ADX (Wilder calculation): more precisely, it controls the strength of the trend without hidden smoothing.
There is a clear separation of market modes: the background of the chart highlights the condition: trend up/down or sideways (range).
Signal tags: Long TPB / Short TPB for pullbacks in the trend, Long MR / Short MR for a return to the average.
A minimum of “noise": neat colors, clear captions, without unnecessary graphics.
How to read signals
Trend Pullback
Long TPB — ADX ≥ threshold, price returns above fast EMA, RSI > 45.
Short TPB — ADX ≥ threshold, price goes below fast EMA, RSI < 55.
Mean-Reversion
Long MR — sideways (ADX < threshold), price below lower BB, RSI < 30, confirmation of reversal.
Short MR — sideways (ADX < threshold), price above upper BB, RSI > 70, reversal confirmation.
Parameters (Inputs)
EMA fast / EMA slow — fast and slow EMA (default 20/50).
ADX length / threshold — period and trend strength threshold.
BB length / mult — period and Bollinger Bands multiplier.
RSI length — RSI period.
Show labels/background — enable mode signatures and highlighting.
Recommendations for use
Timeframes: from M15 to H4. On lower TF, add a filter by the higher trend (e.g. H1/H4 EMA).
Instruments: XAUUSD, FX majors, indices, liquid futures and crypto pairs.
Risk management: for TPB, use SL behind the local swing extremum/below the EMA zone; for MR, use SL behind the external BB.
Filters: avoid entering against strong news; prioritize MR when volatility is low, and TPB when volatility is high.
Alerts
Create standard alerts based on the appearance of Long/Short TPB and Long/Short MR labels — the indicator provides clear conditions for auto-entry/notifications.
Important
The indicator is not
The indicator combines two logics in one tool:
Trend Pullback: Entries in the direction of the dominant trend after a short-term pullback to the EMA.
Return to the mean (Mean-Reversal): countertrend trades from external Bollinger bands with an RSI filter.
Key Features
Manual ADX (Wilder calculation): more precisely, it controls the strength of the trend without hidden smoothing.
There is a clear separation of market modes: the background of the chart highlights the condition: trend up/down or sideways (range).
Signal tags: Long TPB / Short TPB for pullbacks in the trend, Long MR / Short MR for a return to the average.
A minimum of “noise": neat colors, clear captions, without unnecessary graphics.
How to read signals
Trend Pullback
Long TPB — ADX ≥ threshold, price returns above fast EMA, RSI > 45.
Short TPB — ADX ≥ threshold, price goes below fast EMA, RSI < 55.
Mean-Reversion
Long MR — sideways (ADX < threshold), price below lower BB, RSI < 30, confirmation of reversal.
Short MR — sideways (ADX < threshold), price above upper BB, RSI > 70, reversal confirmation.
Parameters (Inputs)
EMA fast / EMA slow — fast and slow EMA (default 20/50).
ADX length / threshold — period and trend strength threshold.
BB length / mult — period and Bollinger Bands multiplier.
RSI length — RSI period.
Show labels/background — enable mode signatures and highlighting.
Recommendations for use
Timeframes: from M15 to H4. On lower TF, add a filter by the higher trend (e.g. H1/H4 EMA).
Instruments: XAUUSD, FX majors, indices, liquid futures and crypto pairs.
Risk management: for TPB, use SL behind the local swing extremum/below the EMA zone; for MR, use SL behind the external BB.
Filters: avoid entering against strong news; prioritize MR when volatility is low, and TPB when volatility is high.
Alerts
Create standard alerts based on the appearance of Long/Short TPB and Long/Short MR labels — the indicator provides clear conditions for auto-entry/notifications.
Important
The indicator is not
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.