OPEN-SOURCE SCRIPT
Crypto PCA [LuxAlgo]

The Crypto PCA [LuxAlgo] indicator provides a sophisticated, multi-asset sentiment gauge by applying Principal Component Analysis (PCA) to a basket of the top 20 cryptocurrencies.
By extracting the primary driver of variance across these assets, the tool offers a "market-wide" oscillator that filters out individual coin noise to highlight the dominant trend and sentiment shifts in the crypto space.
In modern quantitative finance, PCA is used to reduce dimensionality and identify the underlying factors that move a group of assets. This indicator brings that institutional-grade approach to the retail trader, condensing the price action of Bitcoin, Ethereum, Solana, and 17 other majors into a single, actionable signal.
🔶 USAGE
The script serves as a macro-sentiment oscillator, allowing traders to see the "hidden" force driving the crypto market. It is designed to identify when the market is moving in unison and when that collective movement has reached an extreme.
🔹 Identifying Market Regimes
The primary use of the PCA line (PC1) is to determine the current market regime. When the oscillator is above the zero line and colored green, it indicates that the majority of the top 20 assets are experiencing positive variance, signaling a broad bullish regime. Conversely, when the line is below zero and colored red, the market is in a collective bearish state. Traders can use this to align their individual trades with the direction of the total market energy.
🔹 Using Snapshot Mode for Situational Analysis
While the continuous mode is ideal for long-term trend following, the Snapshot Mode provides a focused view of market dynamics over the most recent lookback window. This mode isolates the current sentiment cycle, allowing traders to see the specific trajectory and "shape" of the latest move without the influence of older historical data.
By enabling Snapshot Mode, you can analyze the immediate internal structure of the market. It is particularly useful for identifying whether a recent pump or dump is a coordinated market-wide event or a more fragmented move. This helps in distinguishing between a broad structural shift and a temporary volatility spike.
🔹 Spotting Overextended Sentiment
The indicator includes dashed horizontal lines at +2 and -2, representing standard deviation thresholds. Because the assets are standardized before calculation, these levels mark statistical extremes.
🔹 Gauging Relative Strength
The faint "ghost" lines in the background represent the individual standardized price paths of the 20 included assets. By comparing these to the main PCA line, traders can identify leaders and laggards. An asset line that stays consistently above the PCA line during a rally is exhibiting relative strength, while an asset trailing below the PCA line is underperforming the market average.
🔶 DETAILS
The indicator follows a rigorous mathematical pipeline to ensure the data is statistically significant and comparable across assets with different price scales.
🔹 Standardization (Z-Scores)
Before performing PCA, every asset must be on the same scale. The script converts the price of all 20 assets into Z-scores based on the user-defined Lookback Period. A Z-score tells us how many standard deviations a price is from its mean. This allows the movement of a high-priced asset like BTC to be mathematically compared to a lower-priced asset like PEPE.
🔹 The Basket & PCA Approximation
The indicator includes the following assets: BTC, ETH, BNB, XRP, SOL, TRX, DOGE, ADA, BCH, WBTC, XLM, LTC, HBAR, LINK, AVAX, PEPE, DOT, UNI, NEAR, and ICP.
The script uses a correlation-based approximation to find the First Principal Component. It calculates the correlation of each asset to the equally weighted basket and uses these correlations as "loadings" to compute the PC1. This ensures that assets moving in sync with the general market trend are given higher priority in the final oscillator value.
🔹 Why PCA?
Most "Crypto Indices" are simply weighted averages. PCA is superior because it identifies the commonality between assets. If 18 coins are moving up and 2 are moving down, PCA gives more weight to the 18 moving together, as they represent the "Principal Component" of the market's current energy.
🔶 SETTINGS
🔹 Main Settings
🔹 Visual Settings
By extracting the primary driver of variance across these assets, the tool offers a "market-wide" oscillator that filters out individual coin noise to highlight the dominant trend and sentiment shifts in the crypto space.
In modern quantitative finance, PCA is used to reduce dimensionality and identify the underlying factors that move a group of assets. This indicator brings that institutional-grade approach to the retail trader, condensing the price action of Bitcoin, Ethereum, Solana, and 17 other majors into a single, actionable signal.
🔶 USAGE
The script serves as a macro-sentiment oscillator, allowing traders to see the "hidden" force driving the crypto market. It is designed to identify when the market is moving in unison and when that collective movement has reached an extreme.
🔹 Identifying Market Regimes
The primary use of the PCA line (PC1) is to determine the current market regime. When the oscillator is above the zero line and colored green, it indicates that the majority of the top 20 assets are experiencing positive variance, signaling a broad bullish regime. Conversely, when the line is below zero and colored red, the market is in a collective bearish state. Traders can use this to align their individual trades with the direction of the total market energy.
🔹 Using Snapshot Mode for Situational Analysis
While the continuous mode is ideal for long-term trend following, the Snapshot Mode provides a focused view of market dynamics over the most recent lookback window. This mode isolates the current sentiment cycle, allowing traders to see the specific trajectory and "shape" of the latest move without the influence of older historical data.
By enabling Snapshot Mode, you can analyze the immediate internal structure of the market. It is particularly useful for identifying whether a recent pump or dump is a coordinated market-wide event or a more fragmented move. This helps in distinguishing between a broad structural shift and a temporary volatility spike.
🔹 Spotting Overextended Sentiment
The indicator includes dashed horizontal lines at +2 and -2, representing standard deviation thresholds. Because the assets are standardized before calculation, these levels mark statistical extremes.
- Overbought Extremes: When the PCA line exceeds +2, the broad market is significantly overextended to the upside. This often precedes a cooling-off period or a mean-reversion event across the entire sector.
- Oversold Extremes: When the PCA line drops below -2, it suggests a "panic" or exhausted selling state across the basket. This can signal potential bottoming interest or a relief rally.
🔹 Gauging Relative Strength
The faint "ghost" lines in the background represent the individual standardized price paths of the 20 included assets. By comparing these to the main PCA line, traders can identify leaders and laggards. An asset line that stays consistently above the PCA line during a rally is exhibiting relative strength, while an asset trailing below the PCA line is underperforming the market average.
🔶 DETAILS
The indicator follows a rigorous mathematical pipeline to ensure the data is statistically significant and comparable across assets with different price scales.
🔹 Standardization (Z-Scores)
Before performing PCA, every asset must be on the same scale. The script converts the price of all 20 assets into Z-scores based on the user-defined Lookback Period. A Z-score tells us how many standard deviations a price is from its mean. This allows the movement of a high-priced asset like BTC to be mathematically compared to a lower-priced asset like PEPE.
🔹 The Basket & PCA Approximation
The indicator includes the following assets: BTC, ETH, BNB, XRP, SOL, TRX, DOGE, ADA, BCH, WBTC, XLM, LTC, HBAR, LINK, AVAX, PEPE, DOT, UNI, NEAR, and ICP.
The script uses a correlation-based approximation to find the First Principal Component. It calculates the correlation of each asset to the equally weighted basket and uses these correlations as "loadings" to compute the PC1. This ensures that assets moving in sync with the general market trend are given higher priority in the final oscillator value.
🔹 Why PCA?
Most "Crypto Indices" are simply weighted averages. PCA is superior because it identifies the commonality between assets. If 18 coins are moving up and 2 are moving down, PCA gives more weight to the 18 moving together, as they represent the "Principal Component" of the market's current energy.
🔶 SETTINGS
🔹 Main Settings
- Lookback Period (N): Determines the window used for Z-score standardization and PCA calculation. A shorter period makes the indicator more reactive, while a longer period identifies macro-cycle shifts.
- Z-Score Smoothing: Applies a Simple Moving Average (SMA) to the standardized asset values before the PCA calculation. This effectively filters out high-frequency noise and produces a smoother principal component line, which is useful for reducing false regime shifts in volatile markets.
- Enable Snapshot Mode: Switches the visual output from a continuous rolling line to a static view of the PCA over the most recent lookback window.
🔹 Visual Settings
- Standardized Assets Color: Controls the color and transparency of the 20 individual asset lines.
- Bull/Bear Colors: Defines the colors used for positive and negative market sentiment.
Disclaimer: This indicator is a statistical tool for sentiment analysis and does not constitute financial advice. The PCA approach measures variance and correlation, not guaranteed future direction.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ 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 อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน