PROTECTED SOURCE SCRIPT
Composite PR Signal (Trend↔Revert + ADX gate)

Core Components
1. Dynamic Inputs
Max/PR windows (maxLen, prWin) – define historical lookbacks for oscillators and percentile ranks.
Smoothing (smooth) – applies an EMA filter to stabilize composite scores.
Threshold (th) – governs entry sensitivity.
Holding period (hBars) – maximum bars allowed in a trade.
Execution options – allow shorting, fast approximations for PR and CCI.
2. Custom Utility Functions
The script implements optimized versions of common TA operations:
Rolling sums, delays, and moving averages (EMA, RMA, SMA).
Lazy rolling extrema (efficient highest/lowest lookups).
Stateful arrays for tracking oscillator values across bars.
Fast approximations for percentile ranks and indicators.
3. Indicators Used
The system calculates a broad set of oscillators, including:
Trend/Momentum: ROC, TRIX, TSI, MACD histogram, OBV ROC, AO, CMF, BOP, UO, ADX.
Reversion/Oscillators: RSI, Stochastic K/D, MFI, Williams %R, CCI, CMO.
Each is converted into a percentile rank (PR) to normalize values between 0–100.
4. Composite Scoring
Two composite signals are built:
Trend Score – averages normalized outputs of momentum indicators.
Reversion Score – averages normalized outputs of oscillators prone to mean reversion.
ADX Gate – when ADX PR is high, the strategy favors trend score; when low, it favors reversion score.
Final score is smoothed and compared against entry thresholds.
5. Trade Logic
Entry:
Long: When composite score crosses above +th.
Short: When composite score crosses below -th (if enabled).
Exit:
Opposite crossover signal.
Or trade duration exceeds hBars.
6. Risk/Execution Parameters
Initial capital: 100,000
Commission: 0.01% per trade
Fixed order size: 100 units
No pyramiding
Intended Use
This script is designed for:
Swing trading across multiple assets (equities, forex, crypto).
Adapting to market regimes — capturing breakouts during strong trends, but fading moves when markets are choppy.
1. Dynamic Inputs
Max/PR windows (maxLen, prWin) – define historical lookbacks for oscillators and percentile ranks.
Smoothing (smooth) – applies an EMA filter to stabilize composite scores.
Threshold (th) – governs entry sensitivity.
Holding period (hBars) – maximum bars allowed in a trade.
Execution options – allow shorting, fast approximations for PR and CCI.
2. Custom Utility Functions
The script implements optimized versions of common TA operations:
Rolling sums, delays, and moving averages (EMA, RMA, SMA).
Lazy rolling extrema (efficient highest/lowest lookups).
Stateful arrays for tracking oscillator values across bars.
Fast approximations for percentile ranks and indicators.
3. Indicators Used
The system calculates a broad set of oscillators, including:
Trend/Momentum: ROC, TRIX, TSI, MACD histogram, OBV ROC, AO, CMF, BOP, UO, ADX.
Reversion/Oscillators: RSI, Stochastic K/D, MFI, Williams %R, CCI, CMO.
Each is converted into a percentile rank (PR) to normalize values between 0–100.
4. Composite Scoring
Two composite signals are built:
Trend Score – averages normalized outputs of momentum indicators.
Reversion Score – averages normalized outputs of oscillators prone to mean reversion.
ADX Gate – when ADX PR is high, the strategy favors trend score; when low, it favors reversion score.
Final score is smoothed and compared against entry thresholds.
5. Trade Logic
Entry:
Long: When composite score crosses above +th.
Short: When composite score crosses below -th (if enabled).
Exit:
Opposite crossover signal.
Or trade duration exceeds hBars.
6. Risk/Execution Parameters
Initial capital: 100,000
Commission: 0.01% per trade
Fixed order size: 100 units
No pyramiding
Intended Use
This script is designed for:
Swing trading across multiple assets (equities, forex, crypto).
Adapting to market regimes — capturing breakouts during strong trends, but fading moves when markets are choppy.
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。