PROTECTED SOURCE SCRIPT
alzaem RSPS

This script compares 30 different tokens and find the best performing asset from the 30. The indicator tracks the changes by plotting the equity and changes in the equity.
The script is totally costumizable, feel free to change any thing.
The current configurations are the ones that suit my own approach feel free to find you suitable configuration.
Summary of how the script works:
The provided script is a sophisticated trading indicator written in Pine Script (version 6) for the TradingView platform, named "alzaem RSPS" (Relative Strength Portfolio System). It is designed to analyze and rank multiple assets (up to 30 cryptocurrencies) based on various performance metrics, generate trading signals, and manage a portfolio with an equity curve. Below is a summary of what the script does:
Key Functionalities:
Asset Selection and Scoring:
The script allows users to input up to 30 cryptocurrency symbols (e.g., XRPUSDT, BNBUSDT) and a benchmark (e.g., BTCUSDT).
Assets are scored using a combination of performance metrics, including:
Momentum: Relative strength compared to other assets over a specified period.
Sharpe, Sortino, and Omega Ratios: Risk-adjusted return metrics.
Other Metrics: Percentage gain, Conditional Value at Risk (CVaR), Ulcer Index, Treynor Ratio, Up-Down Capture, and Information Ratio (configurable via inputs).
Scores are calculated by comparing each asset’s metrics against the median and applying a momentum-based ranking system (f_condition function).
Assets must meet a minimum score threshold to be considered for ranking.
Ranking and Winner Selection:
Assets are ranked based on their total scores (initial scores + momentum scores).
The top-ranked assets are stored in the final_winners array, with options to display specific ranks (e.g., Rank 1, Rank 2, or combinations like Rank 1 & 2).
Users can select specific assets to monitor their scores in a table.
Technical Analysis and Signal Generation:
The script uses a combination of technical indicators to generate Long and Short signals:
Double Exponential Moving Average (DEMA): Smooths price data.
Gaussian Filter: Applied to DEMA for noise reduction.
Running Moving Average (RMA): Further smooths the filtered DEMA.
Average True Range (ATR): Creates dynamic bands around the RMA to define Long (LongR) and Short (ShortR) thresholds.
Signals:
Long Signal: When the closing price is above the upper ATR band (LongR).
Short Signal: When the closing price is below the lower ATR band (ShortR).
Signals are plotted as labels on the chart (e.g., "Long" or "Short") if enabled.
Market Trend Analysis:
Analyzes the broader market trend using a market index (e.g., CRYPTOCAP:TOTAL).
Uses multiple indicators to determine market conditions:
Moving Average: Compares market close to a chosen moving average (e.g., LSMA, EMA).
Range Calculations: Uses highest price levels with multipliers to set thresholds.
RSI-based Valuation: Determines if the market is trending or mean-reverting.
Augmented Dickey-Fuller (ADF) Test: Optionally confirms trend or mean-reverting behavior.
Combines these factors to decide if the system should be "in position" (active trading) or not.
Portfolio Management and Equity Curve:
Tracks the portfolio’s equity starting from a user-defined date.
Updates equity based on the performance of selected top-ranked assets (e.g., Rank 1, Rank 1 & 2).
Applies leverage (fixed at 1 in the script) to calculate returns.
Compares the system’s performance to a Buy-and-Hold BTC strategy (equityNot).
Calculates performance metrics like Net Profit, Sharpe Ratio, Sortino Ratio, Omega Ratio, and Maximum Drawdown for both the system and BTC Buy-and-Hold.
Visualization and Output:
Table Display:
Shows system performance metrics (Sharpe, Sortino, Omega, Max Drawdown, Net Profit).
Displays Buy-and-Hold BTC metrics for comparison.
Lists top 5 assets with their scores and user-selected assets’ scores.
Indicates system state (ON/OFF) based on inPosition status.
Shows winner symbols (top-ranked assets).
Chart Elements:
Plots RMA, ATR bands, and candlesticks with customizable color schemes.
Displays equity curves for the system and BTC Buy-and-Hold.
Adds labels for Long/Short signals and equity curve annotations.
Alerts: Triggers alerts for the top-winning coin on each bar close.
Customization:
Extensive input options for:
Timeframes (analysis, short-term, long-term).
Periods for various indicators (DEMA, Gaussian, RMA, ATR, etc.).
Scoring metrics to include/exclude (e.g., use Sharpe, use Momentum).
Visual settings (color modes, label display).
Market trend conditions (e.g., use ADF, valuation thresholds).
Allows users to force display of winners or disable in-position rules.
Workflow Summary:
Data Retrieval: Fetches price and performance data for 30 assets and a market index.
Signal Generation: Uses DEMA, Gaussian filter, RMA, and ATR to generate Long/Short signals.
Asset Scoring: Calculates scores based on user-selected metrics and momentum.
Ranking: Ranks assets and selects top performers.
Market Trend Check: Determines if the system should be active based on market conditions.
Portfolio Update: Adjusts equity based on top-ranked assets’ performance.
Visualization: Displays results in a table, plots indicators, and shows equity curves.
Alerts: Notifies users of the top-winning asset.
Purpose:
The script is designed for traders who want to systematically select and trade cryptocurrencies based on relative strength and risk-adjusted performance metrics. It combines technical analysis, portfolio management, and market trend analysis to create a robust trading system, with a focus on outperforming a simple Buy-and-Hold BTC strategy.
Notes:
Users need to configure inputs carefully to align with their trading strategy and risk tolerance.
The script is complex and resource-intensive due to the large number of assets and calculations.
apply the script to the" TOTAL" chart only on 1D time frame.
If any help is needed contact me in direct messages or on my instagram account: @az.3ym
The script is totally costumizable, feel free to change any thing.
The current configurations are the ones that suit my own approach feel free to find you suitable configuration.
Summary of how the script works:
The provided script is a sophisticated trading indicator written in Pine Script (version 6) for the TradingView platform, named "alzaem RSPS" (Relative Strength Portfolio System). It is designed to analyze and rank multiple assets (up to 30 cryptocurrencies) based on various performance metrics, generate trading signals, and manage a portfolio with an equity curve. Below is a summary of what the script does:
Key Functionalities:
Asset Selection and Scoring:
The script allows users to input up to 30 cryptocurrency symbols (e.g., XRPUSDT, BNBUSDT) and a benchmark (e.g., BTCUSDT).
Assets are scored using a combination of performance metrics, including:
Momentum: Relative strength compared to other assets over a specified period.
Sharpe, Sortino, and Omega Ratios: Risk-adjusted return metrics.
Other Metrics: Percentage gain, Conditional Value at Risk (CVaR), Ulcer Index, Treynor Ratio, Up-Down Capture, and Information Ratio (configurable via inputs).
Scores are calculated by comparing each asset’s metrics against the median and applying a momentum-based ranking system (f_condition function).
Assets must meet a minimum score threshold to be considered for ranking.
Ranking and Winner Selection:
Assets are ranked based on their total scores (initial scores + momentum scores).
The top-ranked assets are stored in the final_winners array, with options to display specific ranks (e.g., Rank 1, Rank 2, or combinations like Rank 1 & 2).
Users can select specific assets to monitor their scores in a table.
Technical Analysis and Signal Generation:
The script uses a combination of technical indicators to generate Long and Short signals:
Double Exponential Moving Average (DEMA): Smooths price data.
Gaussian Filter: Applied to DEMA for noise reduction.
Running Moving Average (RMA): Further smooths the filtered DEMA.
Average True Range (ATR): Creates dynamic bands around the RMA to define Long (LongR) and Short (ShortR) thresholds.
Signals:
Long Signal: When the closing price is above the upper ATR band (LongR).
Short Signal: When the closing price is below the lower ATR band (ShortR).
Signals are plotted as labels on the chart (e.g., "Long" or "Short") if enabled.
Market Trend Analysis:
Analyzes the broader market trend using a market index (e.g., CRYPTOCAP:TOTAL).
Uses multiple indicators to determine market conditions:
Moving Average: Compares market close to a chosen moving average (e.g., LSMA, EMA).
Range Calculations: Uses highest price levels with multipliers to set thresholds.
RSI-based Valuation: Determines if the market is trending or mean-reverting.
Augmented Dickey-Fuller (ADF) Test: Optionally confirms trend or mean-reverting behavior.
Combines these factors to decide if the system should be "in position" (active trading) or not.
Portfolio Management and Equity Curve:
Tracks the portfolio’s equity starting from a user-defined date.
Updates equity based on the performance of selected top-ranked assets (e.g., Rank 1, Rank 1 & 2).
Applies leverage (fixed at 1 in the script) to calculate returns.
Compares the system’s performance to a Buy-and-Hold BTC strategy (equityNot).
Calculates performance metrics like Net Profit, Sharpe Ratio, Sortino Ratio, Omega Ratio, and Maximum Drawdown for both the system and BTC Buy-and-Hold.
Visualization and Output:
Table Display:
Shows system performance metrics (Sharpe, Sortino, Omega, Max Drawdown, Net Profit).
Displays Buy-and-Hold BTC metrics for comparison.
Lists top 5 assets with their scores and user-selected assets’ scores.
Indicates system state (ON/OFF) based on inPosition status.
Shows winner symbols (top-ranked assets).
Chart Elements:
Plots RMA, ATR bands, and candlesticks with customizable color schemes.
Displays equity curves for the system and BTC Buy-and-Hold.
Adds labels for Long/Short signals and equity curve annotations.
Alerts: Triggers alerts for the top-winning coin on each bar close.
Customization:
Extensive input options for:
Timeframes (analysis, short-term, long-term).
Periods for various indicators (DEMA, Gaussian, RMA, ATR, etc.).
Scoring metrics to include/exclude (e.g., use Sharpe, use Momentum).
Visual settings (color modes, label display).
Market trend conditions (e.g., use ADF, valuation thresholds).
Allows users to force display of winners or disable in-position rules.
Workflow Summary:
Data Retrieval: Fetches price and performance data for 30 assets and a market index.
Signal Generation: Uses DEMA, Gaussian filter, RMA, and ATR to generate Long/Short signals.
Asset Scoring: Calculates scores based on user-selected metrics and momentum.
Ranking: Ranks assets and selects top performers.
Market Trend Check: Determines if the system should be active based on market conditions.
Portfolio Update: Adjusts equity based on top-ranked assets’ performance.
Visualization: Displays results in a table, plots indicators, and shows equity curves.
Alerts: Notifies users of the top-winning asset.
Purpose:
The script is designed for traders who want to systematically select and trade cryptocurrencies based on relative strength and risk-adjusted performance metrics. It combines technical analysis, portfolio management, and market trend analysis to create a robust trading system, with a focus on outperforming a simple Buy-and-Hold BTC strategy.
Notes:
Users need to configure inputs carefully to align with their trading strategy and risk tolerance.
The script is complex and resource-intensive due to the large number of assets and calculations.
apply the script to the" TOTAL" chart only on 1D time frame.
If any help is needed contact me in direct messages or on my instagram account: @az.3ym
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya dengan percuma dan tanpa had – ketahui lebih lanjut di sini.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.