PROTECTED SOURCE SCRIPT
Performance Diff vs Benchmark (Visible Range)

Performance Difference vs Benchmark (Visible Range)
This indicator compares the relative performance of the current asset against a benchmark (e.g. SPY) only within the currently visible chart range.
Instead of using a fixed historical anchor, the calculation automatically resets when you zoom or scroll the chart, always using the first visible bar as the starting point.
How it works
The indicator retrieves the benchmark price using the same timeframe as the chart.
When the visible range changes, both the asset and the benchmark are re-anchored to their first visible close.
It then calculates:
- Asset performance (%)
- Benchmark performance (%)
- Performance difference = Asset – Benchmark
The result is shown only inside the visible window.
Visual interpretation
- Green area above 0 → the asset is outperforming the benchmark
- Red area below 0 → the asset is underperforming the benchmark
- The zero line represents equal performance.
A label on the right edge of the chart displays the current performance difference in %.
Why this is useful
Instantly measure relative strength without manual anchors
Ideal for:
Sector vs index comparison
Stock vs ETF analysis
Pair trading & relative momentum
Works naturally with zooming, scrolling, and multi-timeframe analysis
Inputs
Benchmark symbol (selectable from the indicator settings)
Notes
The indicator is designed for visual, comparative analysis, not absolute performance tracking.
Results update dynamically based on what is currently visible on the chart.
This indicator compares the relative performance of the current asset against a benchmark (e.g. SPY) only within the currently visible chart range.
Instead of using a fixed historical anchor, the calculation automatically resets when you zoom or scroll the chart, always using the first visible bar as the starting point.
How it works
The indicator retrieves the benchmark price using the same timeframe as the chart.
When the visible range changes, both the asset and the benchmark are re-anchored to their first visible close.
It then calculates:
- Asset performance (%)
- Benchmark performance (%)
- Performance difference = Asset – Benchmark
The result is shown only inside the visible window.
Visual interpretation
- Green area above 0 → the asset is outperforming the benchmark
- Red area below 0 → the asset is underperforming the benchmark
- The zero line represents equal performance.
A label on the right edge of the chart displays the current performance difference in %.
Why this is useful
Instantly measure relative strength without manual anchors
Ideal for:
Sector vs index comparison
Stock vs ETF analysis
Pair trading & relative momentum
Works naturally with zooming, scrolling, and multi-timeframe analysis
Inputs
Benchmark symbol (selectable from the indicator settings)
Notes
The indicator is designed for visual, comparative analysis, not absolute performance tracking.
Results update dynamically based on what is currently visible on the chart.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.