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
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。