OPEN-SOURCE SCRIPT
Relative Performance Areas [LuxAlgo]

The Relative Performance Areas tool enables traders to analyze the relative performance of any asset against a user-selected benchmark directly on the chart, session by session.
The tool features three display modes for rescaled benchmark prices, as well as a statistics panel providing relevant information about overperforming and underperforming streaks.
🔶 USAGE

Usage is straightforward. Each session is highlighted with an area displaying the asset price range. By default, a green background is displayed when the asset outperforms the benchmark for the session. A red background is displayed if the asset underperforms the benchmark.
The benchmark is displayed as a green or red line. An extended price area is displayed when the benchmark exceeds the asset price and is set to SPX by default, but traders can choose any ticker from the settings panel.

Using benchmarks to compare performance is a common practice in trading and investing. Using indexes such as the S&P 500 (SPX) or the NASDAQ 100 (NDX) to measure our portfolio's performance provides a clear indication of whether our returns are above or below the broad market.
As the previous chart shows, if we have a long position in the NASDAQ 100 and buy an ETF like QQQ, we can clearly see how this position performs against BTSUSD and GOLD in each session.
Over the last 15 sessions, the NASDAQ 100 outperformed the BTSUSD in eight sessions and the GOLD in six sessions. Conversely, it underperformed the BTCUSD in seven sessions and the GOLD in nine sessions.
🔹 Display Mode

The display mode options in the Settings panel determine how benchmark performance is calculated. There are three display modes for the benchmark:
Comparing net returns between an asset and a benchmark provides traders with a broad view of relative performance and is straightforward.
When traders want a better comparison, they can use rescaled returns. This option scales the benchmark performance using the asset's volatility, providing a fairer comparison.
Standardized returns are the most sophisticated approach. They calculate the z-score of the benchmark returns to determine how many standard deviations they are from the mean. Then, they scale that number using the asset volatility, which is measured by the asset returns standard deviation.
As the chart above shows, different display modes produce different results. All of these methods are useful for making comparisons and accounting for different factors.
🔹 Dashboard

The statistics dashboard is a great addition that allows traders to gain a deep understanding of the relationship between assets and benchmarks.
First, we have raw data on overperforming and underperforming sessions. This shows how many sessions the asset performance at the end of the session was above or below the benchmark.
Next, we have the streaks statistics. We define a streak as two or more consecutive sessions where the asset overperformed or underperformed the benchmark.
Here, we have the number of winning and losing streaks (winning means overperforming and losing means underperforming), the median duration of each streak in sessions, the mode (the number of sessions that occurs most frequently), and the percentages of streaks with durations equal to or greater than three, four, five, and six sessions.
As the image shows, these statistics are useful for traders to better understand the relative behavior of different assets.
🔶 SETTINGS
🔹 Dashboard
🔹 Style
The tool features three display modes for rescaled benchmark prices, as well as a statistics panel providing relevant information about overperforming and underperforming streaks.
🔶 USAGE
Usage is straightforward. Each session is highlighted with an area displaying the asset price range. By default, a green background is displayed when the asset outperforms the benchmark for the session. A red background is displayed if the asset underperforms the benchmark.
The benchmark is displayed as a green or red line. An extended price area is displayed when the benchmark exceeds the asset price and is set to SPX by default, but traders can choose any ticker from the settings panel.
Using benchmarks to compare performance is a common practice in trading and investing. Using indexes such as the S&P 500 (SPX) or the NASDAQ 100 (NDX) to measure our portfolio's performance provides a clear indication of whether our returns are above or below the broad market.
As the previous chart shows, if we have a long position in the NASDAQ 100 and buy an ETF like QQQ, we can clearly see how this position performs against BTSUSD and GOLD in each session.
Over the last 15 sessions, the NASDAQ 100 outperformed the BTSUSD in eight sessions and the GOLD in six sessions. Conversely, it underperformed the BTCUSD in seven sessions and the GOLD in nine sessions.
🔹 Display Mode
The display mode options in the Settings panel determine how benchmark performance is calculated. There are three display modes for the benchmark:
- Net Returns: Uses the raw net returns of the benchmark from the start of the session.
- Rescaled Returns: Uses the benchmark net returns multiplied by the ratio of the benchmark net returns standard deviation to the asset net returns standard deviation.
- Standardized Returns: Uses the z-score of the benchmark returns multiplied by the standard deviation of the asset returns.
Comparing net returns between an asset and a benchmark provides traders with a broad view of relative performance and is straightforward.
When traders want a better comparison, they can use rescaled returns. This option scales the benchmark performance using the asset's volatility, providing a fairer comparison.
Standardized returns are the most sophisticated approach. They calculate the z-score of the benchmark returns to determine how many standard deviations they are from the mean. Then, they scale that number using the asset volatility, which is measured by the asset returns standard deviation.
As the chart above shows, different display modes produce different results. All of these methods are useful for making comparisons and accounting for different factors.
🔹 Dashboard
The statistics dashboard is a great addition that allows traders to gain a deep understanding of the relationship between assets and benchmarks.
First, we have raw data on overperforming and underperforming sessions. This shows how many sessions the asset performance at the end of the session was above or below the benchmark.
Next, we have the streaks statistics. We define a streak as two or more consecutive sessions where the asset overperformed or underperformed the benchmark.
Here, we have the number of winning and losing streaks (winning means overperforming and losing means underperforming), the median duration of each streak in sessions, the mode (the number of sessions that occurs most frequently), and the percentages of streaks with durations equal to or greater than three, four, five, and six sessions.
As the image shows, these statistics are useful for traders to better understand the relative behavior of different assets.
🔶 SETTINGS
- Benchmark: Benchmark for comparison
- Display Mode: Choose how to display the benchmark; Net Returns: Uses the raw net returns of the benchmark. Rescaled Returns: Uses the benchmark net returns multiplied by the ratio of the benchmark and asset standard deviations. Standardized Returns: Uses the benchmark z-score multiplied by the asset standard deviation.
🔹 Dashboard
- Dashboard: Enable or disable the dashboard.
- Position: Select the location of the dashboard.
- Size: Select the dashboard size.
🔹 Style
- Overperforming: Enable or disable displaying overperforming sessions and choose a color.
- Underperforming: Enable or disable displaying underperforming sessions and choose a color.
- Benchmark: Enable or disable displaying the benchmark and choose colors.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Get exclusive indicators & AI trading strategies: luxalgo.com
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Get exclusive indicators & AI trading strategies: luxalgo.com
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。