OPEN-SOURCE SCRIPT
Actualizado Compare Strength with SLOPE

Description
This indicator compares the relative strength between the current asset and a benchmark (e.g., BTC vs. ETH or AAPL vs. SPY) using a linear regression slope of their ratio over time.
The ratio is calculated as: close / benchmark
A linear regression slope is computed over a user-defined window
The slope represents trend strength: if it’s rising, the current asset is outperforming the benchmark
Plots
Gray Line: The raw ratio between the asset and benchmark
Orange Line: The slope of the ratio (shows momentum)
Background Color:
Green: The asset is significantly stronger than the benchmark
Red: The asset is significantly weaker than the benchmark
No color: No clear trend
Settings
Slope Window Length: Number of candles used in the regression (default = 10)
Slope Threshold: Sensitivity of trend detection. Smaller values detect weaker trends.
Example Use Cases
Style Rotation Strategy: Use the slope to determine whether "Growth" or "Value" style is leading.
Pair Trading / Relative Performance: Track which asset is leading in a pair (e.g., BTC vs ETH).
Factor Timing: Serve as a timing model to allocate between different sectors or factors.
Happy trading!
This indicator compares the relative strength between the current asset and a benchmark (e.g., BTC vs. ETH or AAPL vs. SPY) using a linear regression slope of their ratio over time.
The ratio is calculated as: close / benchmark
A linear regression slope is computed over a user-defined window
The slope represents trend strength: if it’s rising, the current asset is outperforming the benchmark
Plots
Gray Line: The raw ratio between the asset and benchmark
Orange Line: The slope of the ratio (shows momentum)
Background Color:
Green: The asset is significantly stronger than the benchmark
Red: The asset is significantly weaker than the benchmark
No color: No clear trend
Settings
Slope Window Length: Number of candles used in the regression (default = 10)
Slope Threshold: Sensitivity of trend detection. Smaller values detect weaker trends.
Example Use Cases
Style Rotation Strategy: Use the slope to determine whether "Growth" or "Value" style is leading.
Pair Trading / Relative Performance: Track which asset is leading in a pair (e.g., BTC vs ETH).
Factor Timing: Serve as a timing model to allocate between different sectors or factors.
Happy trading!
Notas de prensa
Indicator Name: Relative Strength SlopePurpose:
Compare the strength of the current asset to a benchmark (e.g. BTC vs ETH or stock vs index) by computing the linear regression slope of their price ratio.
Inputs:
Benchmark Symbol: Reference symbol to compare against.
Slope Window: Number of bars used to calculate the slope.
Threshold: Minimum slope magnitude to classify trend as meaningful.
Interpretation:
Red background: Current asset is trending stronger than the benchmark (positive slope).
Green background: Benchmark is outperforming the current asset (negative slope).
Gray ratio line: Displays the price ratio between current asset and benchmark.
Orange line: Shows the actual slope value over time.
Notas de prensa
Indicator: Compare Strength (Slope-based)This TradingView indicator compares the relative strength between the current chart asset and a selected benchmark asset. It uses the slope of the log-transformed ratio of the two price series to identify trend bias.
What’s New
We updated the calculation to use math.log(close / benchmark_close) instead of simple division. This log transformation ensures:
Scale invariance across vastly different asset price levels (e.g., BTC vs altcoins)
Symmetrical treatment of upward and downward movements
Smoother slope calculation for better trend sensitivity
Inputs
Symbol: The benchmark asset (e.g., BINANCE:BTCUSDT)
Length: Period used for slope calculation (default: 10)
Multiplier: A scaling factor applied to the log-ratio for better visibility (default: 1000)
Interpretation
Red background: The current asset is stronger than the benchmark (positive slope)
Green background: The current asset is weaker than the benchmark (negative slope)
Flat slope: No clear dominance, trend is neutral
Why Use Log-Ratio + Slope?
Using math.log(price / benchmark) provides a more reliable measure of relative price movement across assets with different nominal values. Applying a slope to this ratio allows us to determine which asset is gaining strength faster.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.