Mar 5, 2025
Portfolio Allocation Diversification

Let’s Get to Work.
Let’s Get to Work.
Intro
The Uptrick: Portfolio Allocation Diversification script is designed to help traders and investors manage multiple assets simultaneously. It generates signals based on various trading systems, allocates capital using different diversification methods, and displays real-time metrics and performance tables on the chart. The indicator compares active trading strategies with a separate long-term holding (HODL) simulation, allowing you to see how a systematic trading approach stacks up against a simple buy-and-hold strategy.
------------------------------------------------------------------------
Trading System Selection
1. No signals (none)
In this mode, the script does not produce bullish or bearish indicators; every asset stays in a neutral stance. This setup is useful if you prefer to observe how capital might be distributed based solely on the chosen diversification method, with no influence from directional signals.
2. rsi – neutral
This mode uses an index-based measure of whether an asset appears overbought or oversold. It generates a bearish signal if market conditions point to overbought territory, and a bullish signal if they indicate oversold territory. If neither extreme surfaces, it remains neutral. Some traders apply this in sideways or range-bound conditions, where overbought and oversold levels often hint at possible turning points. It does not specifically account for divergence patterns.
3. rsi – long only
In this setting, the system watches for instances where momentum readings strengthen even if the asset’s price is still under pressure or setting new lows. It also considers oversold levels as potential signals for a bullish setup. When such conditions emerge, the script flags a possible move to the upside, ignoring indications that might otherwise suggest a bearish trend. This approach is generally favored by those who want to concentrate exclusively on identifying price recoveries.
4. rsi – short only
Here, the script focuses on spotting signs of deteriorating momentum while an asset’s price remains relatively high or attempts further gains. It also checks whether the market is drifting into overbought territory, suggesting a potential decline. Under such conditions, it issues a bearish signal. It provides no bullish alerts, making it particularly suitable for traders who look to take advantage of overvalued scenarios or protect themselves against sudden downward moves.
5. Deviation from fair value
Under this system, the script judges how far the current price may have strayed from what is considered typical, taking into account normal fluctuations. If the asset appears to be trading at an unusually low level compared to that reference, it is flagged as bullish. If it seems abnormally high, a bearish signal is issued. This can be applied in various market environments to seek opportunities that arise from perceived mispricing.
6. Percentile channel valuation
In this mode, the script determines where an asset's price stands within a historical distribution, highlighting whether it has reached unusually high or low territory compared to its recent past. When the price reaches what is deemed an extreme reading, it may indicate that a reversal is more likely. This approach is often used by traders who watch for statistical outliers and potential reversion to a more typical trading range.
7. ATH valuation
This technique involves comparing an asset's current price with its previously recorded peak values. The script then interprets whether the price is positioned so far below the all-time high that it looks discounted, or so close to that high that it could be overextended. Such perspective is favored by market participants who want to see if an asset still has ample room to climb before matching historic extremes, or if it is nearing a possible ceiling.
8. Z-score system
Here, the script measures how far above or below a standard reference average an asset's price may be, translated into standardized units. Substantial negative readings can suggest a price that might be unusually weak, prompting a bullish indication, while large positive readings could signal overextension and lead to a bearish call. This method is useful for traders watching for abrupt deviations from a norm that often invite a reversion to more balanced levels.
RSI Divergence Period
This input is particularly relevant for the RSI - Long Only and RSI - Short Only modes. The period determines how many bars in the past you compare RSI values to detect any divergences.
------------------------------------------------------------------------
Diversification Method
Once the script has determined a bullish, bearish, or neutral stance for each asset, it then calculates how to distribute capital among all included assets. The diversification method sets the weighting logic.
1. None
Gives each asset an equal weight. For example, if you have five included assets, each might get 20 percent. This is a simple baseline.
2. Risk-Adjusted Expected Return Using Volatility Clustering
Emphasizes each asset’s average returns relative to its observed risk or volatility tendencies. Assets that exhibit good risk-adjusted returns combined with moderate or lower volatility may receive higher weights than more volatile or less appealing assets. This helps steer capital toward assets that have historically provided a better ratio of return to risk.
3. Relative Strength
Allocates more capital to assets that show stronger price strength compared to a reference (for example, price above a long-term moving average plus a higher RSI). Assets in clear uptrends may be given higher allocations.
4. Trend-Following Indicators
Examines trend-based signals, like positive momentum measurements or upward-trending strength indicators, to assign more weight to assets demonstrating strong directional moves. This suits those who prefer to latch onto trending markets.
5. Volatility-Adjusted Momentum
Looks for assets that have strong price momentum but relatively subdued volatility. The script tends to reward assets that are trending well yet are not too volatile, aiming for stable upward performance rather than massive swings.
6. Correlation-Based Risk Parity
Attempts to weight assets in such a way that the overall portfolio risk is more balanced. Although it is not an advanced correlation matrix approach in a strict sense, it conceptually scales each asset’s weight so no single outlier heavily dominates.
7. Omega Ratio Maximization
Gives preference to assets with higher omega ratios. This ratio can be interpreted as the probability-weighted gains versus losses. Assets with a favorable skew are given more capital.
8. Liquidity-Weighted Valuation
Considers each asset’s average trading liquidity, such as the combination of volume and price. More liquid assets typically receive a higher allocation because they can be entered or exited with lower slippage. If the trading system signals bullishness, that can further boost the allocation, and if it signals bearishness, the allocation might be set to zero or reduced drastically.
9. Drawdown-Controlled Allocation (DCA)
Examines each asset’s maximum drawdown over a recent window. Assets experiencing lighter drawdowns (thus indicating somewhat less downside volatility) receive higher allocations, aiming for a smoother overall equity curve.
------------------------------------------------------------------------
Portfolio and Allocation Settings
Portfolio Value
Defines how much total capital is available for the strategy-based investment portion. For example, if set to 10,000, then each asset’s monetary allocation is determined by the percentage weighting times 10,000.
Use Fixed Allocation
When enabled, the script calculates the initial allocation percentages after 50 bars of data have passed. It then locks those percentages for the remainder of the backtest or real-time session. This feature allows traders to test a static weighting scenario to see how it differs from recalculating weights at each bar.
------------------------------------------------------------------------
HODL Simulator
The script has a separate simulation that accumulates positions in an asset whenever it appears to be recovering from an undervalued state. This parallel tracking is intended to contrast a simple buy-and-hold approach with the more adaptive allocation methods used elsewhere in the script.
HODL Buy Quantity
Each time an asset transitions from an undervalued state to a recovery phase, the simulator executes a purchase of a predefined quantity. For example, if set to 0.5 units, the system will accumulate this amount whenever conditions indicate a shift away from undervaluation.
HODL Buy Threshold
This parameter determines the level at which the simulation identifies an asset as transitioning out of an undervalued state. When the asset moves above this threshold after previously being classified as undervalued, a buy order is triggered. Over time, the performance of these accumulated positions is tracked, allowing for a comparison between this passive accumulation method and the more dynamic allocation strategy.
------------------------------------------------------------------------
Asset Table and Display Settings
The script displays data in multiple tables directly on your chart. You can toggle these tables on or off and position them in various corners of your TradingView screen.
Asset Info Table Position
This table provides key details for each included asset, displaying:
Symbol – Identifies the trading pair being monitored. This helps users keep track of which assets are included in the portfolio allocation process.
Current Trading Signal – Indicates whether the asset is in a bullish, bearish, or neutral state based on the selected trading system. This assists in quickly identifying which assets are showing potential trade opportunities.
Volatility Approximation – Represents the asset’s historical price fluctuations. Higher volatility suggests greater price swings, which can impact risk management and position sizing.
Liquidity Estimate – Reflects the asset’s market liquidity, often based on trading volume and price activity. More liquid assets tend to have lower transaction costs and reduced slippage, making them more favorable for active strategies.
Risk-Adjusted Return Value – Measures the asset’s returns relative to its risk level. This helps in determining whether an asset is generating efficient returns for the level of volatility it experiences, which is useful when making allocation decisions.
2. Strategy Allocation Table Position
Displays how your selected diversification method converts each asset into an allocation percentage. It also shows how much capital is being invested per asset, the cumulative return, standard performance metrics (for example, Sharpe ratio), and the separate HODL return percentage.
Symbol – Displays the asset being analyzed, ensuring clarity in allocation distribution.
Allocation Percentage – Represents the proportion of total capital assigned to each asset. This value is determined by the selected diversification method and helps traders understand how funds are distributed within the portfolio.
Investment Amount – Converts the allocation percentage into a dollar value based on the total portfolio size. This shows the exact amount being invested in each asset.
Cumulative Return – Tracks the total return of each asset over time, reflecting how well it has performed since the strategy began.
Sharpe Ratio – Evaluates the asset’s return in relation to its risk by comparing excess returns to volatility. A higher Sharpe ratio suggests a more favorable risk-adjusted performance.
Sortino Ratio – Similar to the Sharpe ratio, but focuses only on downside risk, making it more relevant for traders who prioritize minimizing losses.
Omega Ratio – Compares the probability of achieving gains versus losses, helping to assess whether an asset provides an attractive risk-reward balance.
Maximum Drawdown – Measures the largest percentage decline from an asset’s peak value to its lowest point. This metric helps traders understand the worst-case loss scenario.
HODL Return Percentage – Displays the hypothetical return if the asset had been bought and held instead of traded actively, offering a direct comparison between passive accumulation and the active strategy.
3. Profit Table
If the Profit Table is activated, it provides a summary of the actual dollar-based gains or losses for each asset and calculates the overall profit of the system. This table includes separate columns for profit excluding HODL and the combined total when HODL gains are included. As seen in the image below, this allows users to compare the performance of the active strategy against a passive buy-and-hold approach. The HODL profit percentage is derived from the Portfolio Value input, ensuring a clear comparison of accumulated returns.
4. Best Performing Asset Table
Focuses on the single highest-returning or highest-profit asset at that moment. It highlights the symbol, the asset’s cumulative returns, risk metrics, and other relevant stats. This helps identify which asset is currently outperforming the rest.
5. Most Profitable Asset
A simpler table that underscores the asset producing the highest absolute dollar profit across the portfolio.
------------------------------------------------------------------------
Multi Asset Selection
You can include up to ten different assets (such as BTCUSDT, ETHUSDT, ADAUSDT, and so on) in this script. Each asset has two inputs: one to enable or disable its inclusion, and another to select its trading pair symbol. Once you enable an asset, the script requests the relevant market data from TradingView.
------------------------------------------------------------------------
Uniqness and Features
1. Multiple Data Fetches
Each asset is pulled from the chart’s timeframe, along with various metrics such as RSI, volatility approximations, and trend indicators.
2. Various Risk and Performance Metrics
The script internally keeps track of different measures, like Sharpe ratio (a measure of average return adjusted for risk), Sortino ratio (which focuses on downside volatility), Omega ratio, and maximum drawdown. These metrics feed into the strategy allocation table, helping you quickly assess the risk-and-return profile of each asset.
3. Real-Time Tables
Instead of having to set up complex spreadsheets or external dashboards, the script updates all tables on every new bar. The color schemes in these tables are designed to draw attention to bullish or bearish signals, positive or negative returns, and so forth.
4. HODL Comparison
You can visually compare the active strategy’s results to a separate continuous buy-on-dips accumulation strategy. This allows for insight into whether your dynamic approach truly beats a simpler, more patient method.
5. Locking Allocations
The Use Fixed Allocation input is convenient for those who want to see how holding a fixed distribution of capital performs over time. It helps in distinguishing between constant rebalancing vs a fixed, set-and-forget style.
------------------------------------------------------------------------
How to use
1. Add the Script to Your Chart
Once added, open the settings panel to configure your asset list, choose a trading system, and select the diversification approach.
2. Select Assets
Pick up to ten symbols to monitor. Disable any you do not want included. Each included asset is then handled for signals, diversification, and performance metrics.
3. Choose Trading System
Decide if you prefer RSI-based signals, a fair-value approach, or a percentile-based method, among others. The script will then flag assets as bullish, bearish, or neutral according to that selection.
4. Pick a Diversification Method
For example, you might choose Trend-Following Indicators if you believe momentum stocks or cryptocurrencies will continue their trends. Or you could use the Omega Ratio approach if you want to reward assets that have had a favorable upside probability.
5. Set Portfolio Value and HODL Parameters
Enter how much capital you want to allocate in total (for the dynamic strategy) and adjust HODL buy quantities and thresholds as desired. (HODL Profit % is calculated from the Portfolio Value)
6. Inspect the Tables
On the chart, the script can display multiple tables showing your allocations, returns, risk metrics, and which assets are leading or lagging. Monitor these to make decisions about capital distribution or see how the strategy evolves.
------------------------------------------------------------------------
Additional Remarks
This script aims to simplify multi-asset portfolio management in a single tool. It emphasizes user-friendliness by color-coding the data in tables, so you do not need extra spreadsheets. The script is also flexible in letting you lock allocations or compare dynamic updates.
Always remember that no script can guarantee profitable outcomes. Real markets involve unpredictability, and real trading includes fees, slippage, and liquidity constraints not fully accounted for here. The script uses real-time and historical data for demonstration and educational purposes, providing a testing environment for various systematic strategies.
Performance Considerations
Due to the complexity of this script, users may experience longer loading times, especially when handling multiple assets or using advanced allocation methods. In some cases, calculations may time out if too many settings are adjusted simultaneously. If this occurs, removing and reapplying the indicator to the chart can help reset the process. Additionally, it is recommended to configure inputs gradually instead of adjusting all parameters at once, as excessive changes can extend the script’s loading duration beyond TradingView’s processing limits.
------------------------------------------------------------------------
Originality
This script stands out by integrating multiple asset management techniques within a single indicator, eliminating the need for multiple scripts or external portfolio tools. Unlike traditional single-asset strategies, it simultaneously evaluates multiple assets, applies systematic allocation logic, and tracks risk-adjusted performance in real time. The script is designed to function within TradingView’s script limitations while still allowing for complex portfolio simulations, making it an efficient tool for traders managing diverse holdings. Additionally, its combination of systematic trading signals with allocation-based diversification provides a structured approach to balancing exposure across different market conditions. The dynamic interplay between adaptive trading strategies and passive accumulation further differentiates it from conventional strategy indicators that focus solely on directional signals without considering capital allocation.
Conclusion
Uptrick: Portfolio Allocation Diversification pulls multiple assets into one efficient workflow, where each asset’s signal, volatility, and performance is measured, then assigned a share of capital according to your selected diversification method. The script accommodates both dynamic rebalancing and a locked allocation style, plus an ongoing HODL simulation for passive accumulation comparison. It neatly visualizes the entire process through on-chart tables that are updated every bar.
Traders and investors looking for ways to manage multiple assets under one unified framework can explore the different modules within this script to find what suits their style. Users can quickly switch among trading systems, vary the allocation approach, or review side-by-side performance metrics to see which method aligns best with their risk tolerance and market perspective.