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
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.