OPEN-SOURCE SCRIPT
已更新

Normalized Portfolio Tracker

67
This script lets you create, visualize, and track a custom portfolio of up to 15 assets directly on TradingView.
It calculates a synthetic "portfolio index" by combining multiple tickers with user-defined weights, automatically normalizing them so the total allocation always equals 100%.
All assets are scaled to a common starting point, allowing you to compare your portfolio’s performance versus any benchmark like SPY, QQQ, or BTC.

🚀 Goal
This script helps traders and investors:
• Understand the combined performance of their portfolio.
• Normalize diverse assets into a single synthetic chart.
• Make portfolio-level insights without relying on external spreadsheets.

🎯 Use Cases
• Backtest your portfolio allocations directly on the chart.
• Compare your portfolio vs. benchmarks like SPY, QQQ, BTC.
• Track thematic baskets (commodities, EV supply chain, regional ETFs).
• Visualize how each component contributes to overall performance.

📊 Features
Weighted Portfolio Performance: Combines selected assets into a synthetic value series.
Base Price Alignment: Each asset is normalized to its starting price at the chosen date.
Dynamic Portfolio Table: Displays symbols, normalized weights (%), equivalent shares (based on each asset’s start price, sums to 100 shares), and a total row that always sums to 100%.
Multi-Asset Support: Works with stocks, ETFs, indices, crypto, or any TradingView-compatible symbol.

⚙️ Configuration
Flexible Portfolio Setup
• Add up to 15 assets with custom weight inputs.
• You can enter any arbitrary numbers (e.g. 30, 15, 55).
• The script automatically normalizes all weights so the total allocation always equals 100%.

Start Date Selection
• Choose any custom start date to normalize all assets.
• The portfolio value is then scaled relative to the main chart symbol, so you can directly compare portfolio performance against benchmarks like SPY or QQQ.

Chart Styles
• Candlestick chart
• Heikin Ashi chart
• Line chart

Custom Display
• Adjustable colors and line widths
• Optionally display asset list, normalized weights, and equivalent shares

⚙️ How It Works
• Fetch OHLC data for each asset.
• Normalizes weights internally so totals = 100%.
• Stores each asset’s base price at the selected start date.
• Calculates equivalent “shares” for each allocation.
• Builds a synthetic portfolio value series by summing weighted contributions.
• Renders as Candlestick, Heikin Ashi, or Line chart.
• Adds a portfolio info table for clarity.

⚠️ Notes
• This script is for visualization only. It does not place trades or auto-rebalance.
• Weight inputs are automatically normalized, so you don’t need to enter exact percentages.
發行說明
Fix: Hide zero-weight items in info table.
發行說明
Dynamic Weight Redistribution: Now automatically redistributes unavailable assets' weights proportionally among available assets to maintain 100% portfolio allocation. This ensures accurate portfolio performance comparison within years of period by preventing start price mismatches when some assets don't exist during the analysis period.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。