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.
Script protegido
Esse script é publicada como código fechado. No entanto, você pode usar ele livremente e sem nenhuma limitação – saiba mais aqui.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script protegido
Esse script é publicada como código fechado. No entanto, você pode usar ele livremente e sem nenhuma limitação – saiba mais aqui.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.