PROTECTED SOURCE SCRIPT
BTC/SOL Spread Strategy

Spread Percentage Trading Strategy
A mean reversion strategy for highly correlated asset pairs (e.g., BTC/SOL) that trades based on price ratio divergence.
CORE CONCEPT
This strategy monitors the logarithmic spread between two correlated assets and generates trading signals when the spread deviates significantly from its historical mean. It only trades the second asset (S2) while using the first asset (S1) as a reference for spread calculation.
HOW IT WORKS
Spread Calculation:
- Computes log spread: log(S1) - log(S2)
- Calculates rolling Z-score of the spread
- Identifies overbought/oversold conditions
Entry Signals:
- Long S2: When spread Z-score crosses above entry threshold (S1 relatively overpriced)
- Short S2: When spread Z-score crosses below negative entry threshold (S2 relatively overpriced)
Exit Signals:
- Positions close when Z-score reverts to exit threshold levels
KEY PARAMETERS
- Window: Rolling period for mean and standard deviation calculation (default: 144)
- Entry Threshold: Z-score level to trigger new positions (default: 1.5)
- Exit Threshold: Z-score level to close positions (default: 0.3)
FEATURES
✓ Vectorized backtesting engine
✓ Built-in parameter optimization
✓ Comprehensive performance metrics
✓ Visual analysis tools
✓ Position sizing with leverage support
RISK WARNING
This strategy:
- Assumes mean-reverting behavior in price ratios
- Does not guarantee future performance
- Uses leverage which amplifies both gains and losses
- Does not include transaction costs in base implementation
- Requires monitoring of correlation breakdown
RECOMMENDED USE
Best suited for pairs with:
- High historical correlation (>0.8)
- Similar market dynamics
- Sufficient liquidity
- Stable volatility patterns
Always backtest with realistic transaction costs and implement proper risk management including stop-losses and position limits.
DISCLAIMER
For educational purposes only. Past performance does not guarantee future results. Trade at your
A mean reversion strategy for highly correlated asset pairs (e.g., BTC/SOL) that trades based on price ratio divergence.
CORE CONCEPT
This strategy monitors the logarithmic spread between two correlated assets and generates trading signals when the spread deviates significantly from its historical mean. It only trades the second asset (S2) while using the first asset (S1) as a reference for spread calculation.
HOW IT WORKS
Spread Calculation:
- Computes log spread: log(S1) - log(S2)
- Calculates rolling Z-score of the spread
- Identifies overbought/oversold conditions
Entry Signals:
- Long S2: When spread Z-score crosses above entry threshold (S1 relatively overpriced)
- Short S2: When spread Z-score crosses below negative entry threshold (S2 relatively overpriced)
Exit Signals:
- Positions close when Z-score reverts to exit threshold levels
KEY PARAMETERS
- Window: Rolling period for mean and standard deviation calculation (default: 144)
- Entry Threshold: Z-score level to trigger new positions (default: 1.5)
- Exit Threshold: Z-score level to close positions (default: 0.3)
FEATURES
✓ Vectorized backtesting engine
✓ Built-in parameter optimization
✓ Comprehensive performance metrics
✓ Visual analysis tools
✓ Position sizing with leverage support
RISK WARNING
This strategy:
- Assumes mean-reverting behavior in price ratios
- Does not guarantee future performance
- Uses leverage which amplifies both gains and losses
- Does not include transaction costs in base implementation
- Requires monitoring of correlation breakdown
RECOMMENDED USE
Best suited for pairs with:
- High historical correlation (>0.8)
- Similar market dynamics
- Sufficient liquidity
- Stable volatility patterns
Always backtest with realistic transaction costs and implement proper risk management including stop-losses and position limits.
DISCLAIMER
For educational purposes only. Past performance does not guarantee future results. Trade at your
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.