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
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.