ابحث في النصوص البرمجية عن "btc走势预测"
BTC Price Spread - Coinbase & Futs - Premiums & DiscountsThis indicator takes the price of Bitcoin on Coinbase and the futures price on Mex, and compares it the average price of Bitcoin across other major exchanges.
This essentials give us a spread at which Bitcoin is going for.
In turn, this could be a possible tool to help determine market sentiment.
This indicator was created for experimental purposes.
Use at your own digression.
BTC Futures Settlement DatesShows the CBOE and CME settlement dates as horizontal lines, with the option to show a 7 day warning in the background. This should hopefully give ample warning.
I intend to update the script as new dates become available but please PM if I've forgotten.
BTC: CME Futures vs. Exchange SpreadsAs you can see, this script plots the current (10-min. delayed) CME Futures price versus Bitfinex, Bitstamp, and Coinbase prices.
It's displayed here on a 30 minute view because at the time of writing the futures have been alive for approximately one day. The script will likely be more useful on longer time frames as a macro-level indicator.
It's pretty simple to adapt this to additional exchanges
OKCoin future diffThis indicator checks the accuracy of okcoin futures against the current index. Example, check how the 1W future from 7 days ago matches the current spot value. The matches are on the 1W, 2W, 3M futures
The indicator bundles them together, makes a weighted average and shows it all.
the thin lines are the futures deltas for each of the futures(check the code to see the color of each).
the thick line is the compound indicator, the line is red when the value is too far off the spot price, black when it's <5%
background is green on "bullish", red for "bearish", take it as you want with many grains of salt :)
there is an input value (default = 1) to adjust time scales. the value is a multiplier for the number of periods in a day.
Example:
1D chart, input = 1
4h chart, input = 4h * 6 = 24h
using the incorrect adjustment for the wrong time scale, makes the indicator (even more) meaningless ;)
MTF MACD 2 By YuthavithiIf you want a good strategy without repaint. This one might be for you. Excellent profitable for BTCUSD3M for OKCoin.
It uses multiple time frame MACD for trading decision. To avoid repaint, set the delay period = 1 for both long term and midterm.
The idea is that, if long term, mid term and current time frame all agree on traidng direction, the trade will take place.
I also uses it in my automated trading bot with good result.
www.tradingview.com
(CRISIS) aggregateBTCvol v0.2.4Aggregate multiple exchange volumes into single indicator
This update adds:
*Moving Average
*Add/change/disable to up 6 securities without touching code.
*Monochrome mode for dark themes.
BTC Volume Index 1.1 beta [Dia]Indicator calculates total volume across multiple bitcoin exchanges. The influence of each exchange can be adjusted seperately.
0 fee exchanges default to 50%
0 fee futures default to 10%
Define custom lookback periods for price breakout detection.
Look for low-volume price reversals in those candles immediately following high volume peaks. The lower the volume and the greater the open/close price difference of that 2nd candle is compared to the previous one, the higher the likelihood of a local top/bottom being in.
Note:
Bar highlighting is still experimental, future versions will include better filtering options.
Use for confirmation only, not as standalone trading system.
Buy/Sell Signal v3
BTC/Gold Scalping Strategy - 5M 1H Timeframe
Description
Advanced trading indicator specifically designed for scalping BTC and Gold on 5-minute and 1-hour timeframes. It uses EMA crossovers with automatic risk management (Stop Loss and Take Profit) based on ATR.
Main Features
- Automatic entry signals: Identifies optimal buy and sell points based on EMA crossovers
- Integrated risk management: Automatically calculates SL and TP according to your preferred risk/reward ratio
- Smart invalidation: Cancels previous positions when a new opposite signal appears
- Clear visualization: Horizontal lines showing entry, stop loss, and take profit in real time
- Informative panel: Table with all information about the active position
- Complete alert system: Notifications for entries, exits, and invalidations
How It Works
The indicator detects trend changes through the crossover of two EMAs:
- Fast EMA (default 5 periods): Quickly responds to price changes
- Slow EMA (default 13 periods): Filters market noise
- BUY Signal: When the fast EMA crosses above the slow EMA
- SELL Signal: When the fast EMA crosses below the slow EMA
Risk Management
- Stop Loss: Placed below/above the low/high of the entry candle, adjusted by ATR
- Take Profit: Automatically calculated according to your configured R:R ratio (default 3:1)
- Invalidation: If an opposite signal appears before TP or SL is hit, the position closes automatically
Visual Elements
- 🟢 BUY Label: Buy signal (lime green)
- 🔴 SELL Label: Sell signal (red)
- ⚠️ INV Icon: Invalidated entry (yellow)
- 🎯 TP Icon: Take Profit reached (green)
- ❌ SL Icon: Stop Loss triggered (red)
- ⚪ White dotted line: Entry price
- 🔴 Red line: Stop Loss level
- 🟢 Green line: Take Profit level
Recommended Settings
For BTC:
- Fast EMA: 5
- Slow EMA: 13
- ATR: 14
- SL Multiplier: 0.5
- Risk:Reward: 3.0
- Candle confirmation: Enabled
For Gold (XAU/USD):
- Fast EMA: 5
- Slow EMA: 13
- ATR: 14
- SL Multiplier: 0.4–0.6 (adjust depending on volatility)
- Risk:Reward: 2.5–3.5
- Candle confirmation: Enabled
Available Alerts
1. 🟢 BUY Signal: Triggered when a new buy opportunity appears
2. 🔴 SELL Signal: Triggered when a new sell opportunity appears
3. 🎯 Take Profit: Notifies when the profit target is reached
4. ❌ Stop Loss: Alerts when stop loss is triggered
5. ⚠️ Invalidated Entry: Alerts when a position is canceled by an opposite signal
Important Notes
- ⏰ Recommended timeframe: 5 minutes and 1 hour
- 📊 Optimized assets: Bitcoin (BTC/USD) and Gold (XAU/USD), including Futures
- ⚠️ No repaint*: Signals do not change once confirmed
- 🎓 Educational use: Always perform your own analysis before trading
- 💰 Capital management: Never risk more than 1–2% of your account per trade
Customizable Parameters
Indicators:
- Fast EMA period (1–50)
- Slow EMA period (1–50)
- ATR period (1–50)
- Stop Loss multiplier (0.1–5.0)
- Risk:Reward ratio (1.0–10.0)
- Candle confirmation (On/Off)
EMA Visualization:
- Show/Hide Fast EMA
- Customizable Fast EMA color
- Show/Hide Slow EMA
- Customizable Slow EMA color
How to Use
1. Add the indicator to your 5-minute chart
2. Adjust parameters according to your trading style
3. Set up alerts to receive notifications
4. Wait for clear BUY or SELL signals
5. Manage the trade following the SL and TP levels displayed
Disclaimer: This indicator is a technical analysis tool. It does not constitute financial advice. Trading carries significant risks and you may lose your capital. Always trade responsibly with proper risk management.
Kernel Market Dynamics [WFO-MAB]Kernel Market Dynamics ════════════════════════════════════════════════════════
⚛️ CORE INNOVATION: KERNEL-BASED DISTRIBUTION ANALYSIS
The Kernel Market Dynamics system represents a fundamental departure from traditional technical indicators. Rather than measuring price levels, momentum, or oscillator extremes, KMD analyzes the statistical distribution of market returns using advanced kernel methods from machine learning theory. This allows the system to detect when market behavior has fundamentally changed—not just when price has moved, but when the underlying probability structure has shifted.
The Distribution Hypothesis:
Traditional indicators assume markets move in predictable patterns. KMD assumes something more profound: markets exist in distinct distributional regimes , and profitable trading opportunities emerge during regime transitions . When the distribution of recent returns diverges significantly from the historical baseline, the market is restructuring—and that's when edge exists.
Maximum Mean Discrepancy (MMD):
At the heart of KMD lies a sophisticated statistical metric called Maximum Mean Discrepancy. MMD measures the distance between two probability distributions by comparing their representations in a high-dimensional feature space created by a kernel function.
The Mathematics:
Given two sets of normalized returns:
• Reference period (X) : Historical baseline (default 100 bars)
• Test period (Y) : Recent behavior (default 20 bars)
MMD is calculated as:
MMD² = E + E - 2·E
Where:
• E = Expected kernel similarity within reference period
• E = Expected kernel similarity within test period
• E = Expected cross-similarity between periods
When MMD is low : Test period behaves like reference (stable regime)
When MMD is high : Test period diverges from reference (regime shift)
The final MMD value is smoothed with EMA(5) to reduce single-bar noise while maintaining responsiveness to genuine distribution changes.
The Kernel Functions:
The kernel function defines how similarity is measured. KMD offers four mathematically distinct kernels, each with different properties:
1. RBF (Radial Basis Function / Gaussian):
• Formula: k(x,y) = exp(-d² / (2·σ²·scale))
• Properties: Most sensitive to distribution changes, smooth decision boundaries
• Best for: Clean data, clear regime shifts, low-noise markets
• Sensitivity: Highest - detects subtle changes
• Use case: Stock indices, major forex pairs, trending environments
2. Laplacian:
• Formula: k(x,y) = exp(-|d| / σ)
• Properties: Medium sensitivity, robust to moderate outliers
• Best for: Standard market conditions, balanced noise/signal
• Sensitivity: Medium - filters minor fluctuations
• Use case: Commodities, standard timeframes, general trading
3. Cauchy (Default - Most Robust):
• Formula: k(x,y) = 1 / (1 + d²/σ²)
• Properties: Heavy-tailed, highly robust to outliers and spikes
• Best for: Noisy markets, choppy conditions, crypto volatility
• Sensitivity: Lower - only major distribution shifts trigger
• Use case: Cryptocurrencies, illiquid markets, volatile instruments
4. Rational Quadratic:
• Formula: k(x,y) = (1 + d²/(2·α·σ²))^(-α)
• Properties: Tunable via alpha parameter, mixture of RBF kernels
• Alpha < 1.0: Heavy tails (like Cauchy)
• Alpha > 3.0: Light tails (like RBF)
• Best for: Adaptive use, mixed market conditions
• Use case: Experimental optimization, regime-specific tuning
Bandwidth (σ) Parameter:
The bandwidth controls the "width" of the kernel, determining sensitivity to return differences:
• Low bandwidth (0.5-1.5) : Narrow kernel, very sensitive
- Treats small differences as significant
- More MMD spikes, more signals
- Use for: Scalping, fast markets
• Medium bandwidth (1.5-3.0) : Balanced sensitivity (recommended)
- Filters noise while catching real shifts
- Professional-grade signal quality
- Use for: Day/swing trading
• High bandwidth (3.0-10.0) : Wide kernel, less sensitive
- Only major distribution changes register
- Fewer, stronger signals
- Use for: Position trading, trend following
Adaptive Bandwidth:
When enabled (default ON), bandwidth automatically scales with market volatility:
Effective_BW = Base_BW × max(0.5, min(2.0, 1 / volatility_ratio))
• Low volatility → Tighter bandwidth (0.5× base) → More sensitive
• High volatility → Wider bandwidth (2.0× base) → Less sensitive
This prevents signal flooding during wild markets and avoids signal drought during calm periods.
Why Kernels Work:
Kernel methods implicitly map data to infinite-dimensional space where complex, nonlinear patterns become linearly separable. This allows MMD to detect distribution changes that simpler statistics (mean, variance) would miss. For example:
• Same mean, different shape : Traditional metrics see nothing, MMD detects shift
• Same volatility, different skew : Oscillators miss it, MMD catches it
• Regime rotation : Price unchanged, but return distribution restructured
The kernel captures the entire distributional signature —not just first and second moments.
🎰 MULTI-ARMED BANDIT FRAMEWORK: ADAPTIVE STRATEGY SELECTION
Rather than forcing one strategy on all market conditions, KMD implements a Multi-Armed Bandit (MAB) system that learns which of seven distinct strategies performs best and dynamically selects the optimal approach in real-time.
The Seven Arms (Strategies):
Each arm represents a fundamentally different trading logic:
ARM 0 - MMD Regime Shift:
• Logic: Distribution divergence with directional bias
• Triggers: MMD > threshold AND direction_bias confirmed AND velocity > 5%
• Philosophy: Trade the regime transition itself
• Best in: Volatile shifts, breakout moments, crisis periods
• Weakness: False alarms in choppy consolidation
ARM 1 - Trend Following:
• Logic: Aligned EMAs with strong ADX
• Triggers: EMA(9) > EMA(21) > EMA(50) AND ADX > 25
• Philosophy: Ride established momentum
• Best in: Strong trending regimes, directional markets
• Weakness: Late entries, whipsaws at reversals
ARM 2 - Breakout:
• Logic: Bollinger Band breakouts with volume
• Triggers: Price crosses BB outer band AND volume > 1.2× average
• Philosophy: Capture volatility expansion events
• Best in: Range breakouts, earnings, news events
• Weakness: False breakouts in ranging markets
ARM 3 - RSI Mean Reversion:
• Logic: RSI extremes with reversal confirmation
• Triggers: RSI < 30 with uptick OR RSI > 70 with downtick
• Philosophy: Fade overbought/oversold extremes
• Best in: Ranging markets, mean-reverting instruments
• Weakness: Fails in strong trends, catches falling knives
ARM 4 - Z-Score Statistical Reversion:
• Logic: Price deviation from 50-period mean
• Triggers: Z-score < -2 (oversold) OR > +2 (overbought) with reversal
• Philosophy: Statistical bounds reversion
• Best in: Stable volatility regimes, pairs trading
• Weakness: Trend continuation through extremes
ARM 5 - ADX Momentum:
• Logic: Strong directional movement with acceleration
• Triggers: ADX > 30 with DI+ or DI- strengthening
• Philosophy: Momentum begets momentum
• Best in: Trending with increasing velocity
• Weakness: Late exits, momentum exhaustion
ARM 6 - Volume Confirmation:
• Logic: OBV trend + volume spike + candle direction
• Triggers: OBV > EMA(20) AND volume > average AND bullish candle
• Philosophy: Follow institutional money flow
• Best in: Liquid markets with reliable volume
• Weakness: Manipulated volume, thin markets
Q-Learning with Rewards:
Each arm maintains a Q-value representing its expected reward. After every bar, the system calculates a reward based on the arm's signal and actual price movement:
Reward Calculation:
If arm signaled LONG:
reward = (close - close ) / close
If arm signaled SHORT:
reward = -(close - close ) / close
If arm signaled NEUTRAL:
reward = 0
Penalty multiplier: If loss > 0.5%, reward × 1.3 (punish big losses harder)
Q-Value Update (Exponential Moving Average):
Q_new = Q_old + α × (reward - Q_old)
Where α (learning rate, default 0.08) controls adaptation speed:
• Low α (0.01-0.05): Slow, stable learning
• Medium α (0.06-0.12): Balanced (recommended)
• High α (0.15-0.30): Fast, reactive learning
This gradually shifts Q-values toward arms that generate positive returns and away from losing arms.
Arm Selection Algorithms:
KMD offers four mathematically distinct selection strategies:
1. UCB1 (Upper Confidence Bound) - Recommended:
Formula: Select arm with max(Q_i + c·√(ln(t)/n_i))
Where:
• Q_i = Q-value of arm i
• c = exploration constant (default 1.5)
• t = total pulls across all arms
• n_i = pulls of arm i
Philosophy: Balance exploitation (use best arm) with exploration (try uncertain arms). The √(ln(t)/n_i) term creates an "exploration bonus" that decreases as an arm gets more pulls, ensuring all arms get sufficient testing.
Theoretical guarantee: Logarithmic regret bound - UCB1 provably converges to optimal arm selection over time.
2. UCB1-Tuned (Variance-Aware UCB):
Formula: Select arm with max(Q_i + √(ln(t)/n_i × min(0.25, V_i + √(2·ln(t)/n_i))))
Where V_i = variance of rewards for arm i
Philosophy: Incorporates reward variance into exploration. Arms with high variance (unpredictable) get less exploration bonus, focusing effort on stable performers.
Better bounds than UCB1 in practice, slightly more conservative exploration.
3. Epsilon-Greedy (Simple Random):
Algorithm:
With probability ε: Select random arm (explore)
With probability 1-ε: Select highest Q-value arm (exploit)
Default ε = 0.10 (10% exploration, 90% exploitation)
Philosophy: Simplest algorithm, easy to understand. Random exploration ensures all arms stay updated but may waste time on clearly bad arms.
4. Thompson Sampling (Bayesian):
The most sophisticated selection algorithm, using true Bayesian probability.
Each arm maintains Beta distribution parameters:
• α (alpha) = successes + 1
• β (beta) = failures + 1
Selection Process:
1. Sample θ_i ~ Beta(α_i, β_i) for each arm using Marsaglia-Tsang Gamma sampler
2. Select arm with highest sample: argmax_i(θ_i)
3. After reward, update:
- If reward > 0: α += |reward| × 100 (increment successes)
- If reward < 0: β += |reward| × 100 (increment failures)
Why Thompson Sampling Works:
The Beta distribution naturally represents uncertainty about an arm's true win rate. Early on with few trials, the distribution is wide (high uncertainty), leading to more exploration. As evidence accumulates, it narrows around the true performance, naturally shifting toward exploitation.
Unlike UCB which uses deterministic confidence bounds, Thompson Sampling is probabilistic—it samples from the posterior distribution of each arm's success rate, providing automatic exploration/exploitation balance without tuning.
Comparison:
• UCB1: Deterministic, guaranteed regret bounds, requires tuning exploration constant
• Thompson: Probabilistic, natural exploration, no tuning required, best empirical performance
• Epsilon-Greedy: Simplest, consistent exploration %, less efficient
• UCB1-Tuned: UCB1 + variance awareness, best for risk-averse
Exploration Constant (c):
For UCB algorithms, this multiplies the exploration bonus:
• Low c (0.5-1.0): Strongly prefer proven arms, rare exploration
• Medium c (1.2-1.8): Balanced (default 1.5)
• High c (2.0-3.0): Frequent exploration, diverse arm usage
Higher exploration constant in volatile/unstable markets, lower in stable trending environments.
🔬 WALK-FORWARD OPTIMIZATION: PREVENTING OVERFITTING
The single biggest problem in algorithmic trading is overfitting—strategies that look amazing in backtest but fail in live trading because they learned noise instead of signal. KMD's Walk-Forward Optimization system addresses this head-on.
How WFO Works:
The system divides time into repeating cycles:
1. Training Window (default 500 bars): Learn arm Q-values on historical data
2. Testing Window (default 100 bars): Validate on unseen "future" data
Training Phase:
• All arms accumulate rewards and update Q-values normally
• Q_train tracks in-sample performance
• System learns which arms work on historical data
Testing Phase:
• System continues using arms but tracks separate Q_test metrics
• Counts trades per arm (N_test)
• Testing performance is "out-of-sample" relative to training
Validation Requirements:
An arm is only "validated" (approved for live use) if:
1. N_test ≥ Minimum Trades (default 10): Sufficient statistical sample
2. Q_test > 0 : Positive out-of-sample performance
Arms that fail validation are blocked from generating signals, preventing the system from trading strategies that only worked on historical data.
Performance Decay:
At the end of each WFO cycle, all Q-values decay exponentially:
Q_new = Q_old × decay_rate (default 0.95)
This ensures old performance doesn't dominate forever. An arm that worked 10 cycles ago but fails recently will eventually lose influence.
Decay Math:
• 0.95 decay after 10 periods → 0.95^10 = 0.60 (40% forgotten)
• 0.90 decay after 10 periods → 0.90^10 = 0.35 (65% forgotten)
Fast decay (0.80-0.90): Quick adaptation, forgets old patterns rapidly
Slow decay (0.96-0.99): Stable, retains historical knowledge longer
WFO Efficiency Metric:
The key metric revealing overfitting:
Efficiency = (Q_test / Q_train) for each validated arm, averaged
• Efficiency > 0.8 : Excellent - strategies generalize well (LOW overfit risk)
• Efficiency 0.5-0.8 : Acceptable - moderate generalization (MODERATE risk)
• Efficiency < 0.5 : Poor - strategies curve-fitted to history (HIGH risk)
If efficiency is low, the system has learned noise. Training performance was good but testing (forward) performance is weak—classic overfitting.
The dashboard displays real-time WFO efficiency, allowing users to gauge system robustness. Low efficiency should trigger parameter review or reduced position sizing.
Why WFO Matters:
Consider two scenarios:
Scenario A - No WFO:
• Arm 3 (RSI Reversion) shows Q-value of 0.15 on all historical data
• System trades it aggressively
• Reality: It only worked during one specific ranging period
• Live trading: Fails because market has trended since backtest
Scenario B - With WFO:
• Arm 3 shows Q_train = 0.15 (good in training)
• But Q_test = -0.05 (loses in testing) with 12 test trades
• N_test ≥ 10 but Q_test < 0 → Arm BLOCKED
• System refuses to trade it despite good backtest
• Live trading: Protected from false strategy
WFO ensures only strategies that work going forward get used, not just strategies that fit the past.
Optimal Window Sizing:
Training Window:
• Too short (100-300): May learn recent noise, insufficient data
• Too long (1000-2000): May include obsolete market regimes
• Recommended: 4-6× testing window (default 500)
Testing Window:
• Too short (50-80): Insufficient validation, high variance
• Too long (300-500): Delayed adaptation to regime changes
• Recommended: 1/5 to 1/4 of training (default 100)
Minimum Trades:
• Too low (5-8): Statistical noise, lucky runs validate
• Too high (30-50): Many arms never validate, system rarely trades
• Recommended: 10-15 (default 10)
⚖️ WEIGHTED CONFLUENCE SYSTEM: MULTI-FACTOR SIGNAL QUALITY
Not all signals are created equal. KMD implements a sophisticated 100-point quality scoring system that combines eight independent factors with different importance weights.
The Scoring Framework:
Each potential signal receives a quality score from 0-100 by accumulating points from aligned factors:
CRITICAL FACTORS (20 points each):
1. Bandit Arm Alignment (20 points):
• Full points if selected arm's signal matches trade direction
• Zero points if arm disagrees
• Weight: Highest - the bandit selected this arm for a reason
2. MMD Regime Quality (20 points):
• Requires: MMD > dynamic threshold AND directional bias confirmed
• Scaled by MMD percentile (how extreme vs history)
• If MMD in top 10% of history: 100% of 20 points
• If MMD at 50th percentile: 50% of 20 points
• Weight: Highest - distribution shift is the core signal
HIGH IMPACT FACTORS (15 points each):
3. Trend Alignment (15 points):
• Full points if EMA(9) > EMA(21) > EMA(50) for longs (inverse for shorts)
• Scaled by ADX strength:
- ADX > 25: 100% (1.0× multiplier) - strong trend
- ADX 20-25: 70% (0.7× multiplier) - moderate trend
- ADX < 20: 40% (0.4× multiplier) - weak trend
• Weight: High - trend is friend, alignment increases probability
4. Volume Confirmation (15 points):
• Requires: OBV > EMA(OBV, 20) aligned with direction
• Scaled by volume ratio: vol_current / vol_average
- Volume 1.5×+ average: 100% of points (institutional participation)
- Volume 1.0-1.5× average: 67% of points (above average)
- Volume below average: 0 points (weak conviction)
• Weight: High - volume validates price moves
MODERATE FACTORS (10 points each):
5. Market Structure (10 points):
• Full points (10) if bullish structure (higher highs, higher lows) for longs
• Partial points (6) if near support level (within 1% of swing low)
• Similar logic inverted for bearish trades
• Weight: Moderate - structure context improves entries
6. RSI Positioning (10 points):
• For long signals:
- RSI < 50: 100% of points (1.0× multiplier) - room to run
- RSI 50-60: 60% of points (0.6× multiplier) - neutral
- RSI 60-70: 30% of points (0.3× multiplier) - elevated
- RSI > 70: 0 points (0× multiplier) - overbought
• Inverse for short signals
• Weight: Moderate - momentum context, not primary signal
BONUS FACTORS (10 points each):
7. Divergence (10 points):
• Full 10 points if bullish divergence detected for long (or bearish for short)
• Zero points otherwise
• Weight: Bonus - leading indicator, adds confidence when present
8. Multi-Timeframe Confirmation (10 points):
• Full 10 points if higher timeframe aligned (HTF EMA trending same direction, RSI supportive)
• Zero points if MTF disabled or HTF opposes
• Weight: Bonus - macro context filter, prevents counter-trend disasters
Total Maximum: 110 points (20+20+15+15+10+10+10+10)
Signal Quality Calculation:
Quality Score = (Accumulated_Points / Maximum_Possible) × 100
Where Maximum_Possible = 110 points if all factors active, adjusts if MTF disabled.
Example Calculation:
Long signal candidate:
• Bandit Arm: +20 (arm signals long)
• MMD Quality: +16 (MMD high, 80th percentile)
• Trend: +11 (EMAs aligned, ADX = 22 → 70% × 15)
• Volume: +10 (OBV rising, vol 1.3× avg → 67% × 15 = 10)
• Structure: +10 (higher lows forming)
• RSI: +6 (RSI = 55 → 60% × 10)
• Divergence: +0 (none present)
• MTF: +10 (HTF bullish)
Total: 83 / 110 × 100 = 75.5% quality score
This is an excellent quality signal - well above threshold (default 60%).
Quality Thresholds:
• Score 80-100 : Exceptional setup - all factors aligned
• Score 60-80 : High quality - most factors supportive (default minimum)
• Score 40-60 : Moderate - mixed confluence, proceed with caution
• Score 20-40 : Weak - minimal support, likely filtered out
• Score 0-20 : Very weak - almost certainly blocked
The minimum quality threshold (default 60) is the gatekeeper. Only signals scoring above this value can trigger trades.
Dynamic Threshold Adjustment:
The system optionally adjusts the threshold based on historical signal distribution:
If Dynamic Threshold enabled:
Recent_MMD_Mean = SMA(MMD, 50)
Recent_MMD_StdDev = StdDev(MMD, 50)
Dynamic_Threshold = max(Base_Threshold × 0.5,
min(Base_Threshold × 2.0,
MMD_Mean + MMD_StdDev × 0.5))
This auto-calibrates to market conditions:
• Quiet markets (low MMD): Threshold loosens (0.5× base)
• Active markets (high MMD): Threshold tightens (2× base)
Signal Ranking Filter:
When enabled, the system tracks the last 100 signal quality scores and only fires signals in the top percentile.
If Ranking Percentile = 75%:
• Collect last 100 signal scores in memory
• Sort ascending
• Threshold = Score at 75th percentile position
• Only signals ≥ this threshold fire
This ensures you're only taking the cream of the crop —top 25% of signals by quality, not every signal that technically qualifies.
🚦 SIGNAL GENERATION: TRANSITION LOGIC & COOLDOWNS
The confluence system determines if a signal qualifies , but the signal generation logic controls when triangles appear on the chart.
Core Qualification:
For a LONG signal to qualify:
1. Bull quality score ≥ signal threshold (default 60)
2. Selected arm signals +1 (long)
3. Cooldown satisfied (bars since last signal ≥ cooldown period)
4. Drawdown protection OK (current drawdown < pause threshold)
5. MMD ≥ 80% of dynamic threshold (slight buffer below full threshold)
For a SHORT signal to qualify:
1. Bear quality score ≥ signal threshold
2. Selected arm signals -1 (short)
3-5. Same as long
But qualification alone doesn't trigger a chart signal.
Three Signal Modes:
1. RESPONSIVE (Default - Recommended):
Signals appear on:
• Fresh qualification (wasn't qualified last bar, now is)
• Direction reversal (was qualified short, now qualified long)
• Quality improvement (already qualified, quality jumps 25%+ during EXTREME regime)
This mode shows new opportunities and significant upgrades without cluttering the chart with repeat signals.
2. TRANSITION ONLY:
Signals appear on:
• Fresh qualification only
• Direction reversal only
This is the cleanest mode - signals only when first qualifying or when flipping direction. Misses re-entries if quality improves mid-regime.
3. CONTINUOUS:
Signals appear on:
• Every bar that qualifies
Testing/debugging mode - shows all qualified bars. Very noisy but useful for understanding when system wants to trade.
Cooldown System:
Prevents signal clustering and overtrading by enforcing minimum bars between signals.
Base Cooldown: User-defined (default 5 bars)
Adaptive Cooldown (Optional):
If enabled, cooldown scales with volatility:
Effective_Cooldown = Base_Cooldown × volatility_multiplier
Where:
ATR_Pct = ATR(14) / Close × 100
Volatility_Multiplier = max(0.5, min(3.0, ATR_Pct / 2.0))
• Low volatility (ATR 1%): Multiplier ~0.5× → Cooldown = 2-3 bars (tight)
• Medium volatility (ATR 2%): Multiplier 1.0× → Cooldown = 5 bars (normal)
• High volatility (ATR 4%+): Multiplier 2.0-3.0× → Cooldown = 10-15 bars (wide)
This prevents excessive trading during wild swings while allowing more signals during calm periods.
Regime Filter:
Three modes controlling which regimes allow trading:
OFF: Trade in any regime (STABLE, TRENDING, SHIFTING, ELEVATED, EXTREME)
SMART (Recommended):
• Regime score = 1.0 for SHIFTING, ELEVATED (optimal)
• Regime score = 0.8 for TRENDING (acceptable)
• Regime score = 0.5 for EXTREME (too chaotic)
• Regime score = 0.2 for STABLE (too quiet)
Quality scores are multiplied by regime score. A 70% quality signal in STABLE regime becomes 70% × 0.2 = 14% → blocked.
STRICT:
• Regime score = 1.0 for SHIFTING, ELEVATED only
• Regime score = 0.0 for all others → hard block
Only trades during optimal distribution shift regimes.
Drawdown Protection:
If current equity drawdown exceeds pause threshold (default 8%), all signals are blocked until equity recovers. This circuit breaker prevents compounding losses during adverse conditions or broken market structure.
🎯 RISK MANAGEMENT: ATR-BASED STOPS & TARGETS
Every signal generates volatility-normalized stop loss and target levels displayed as boxes on the chart.
Stop Loss Calculation:
Stop_Distance = ATR(14) × ATR_Multiplier (default 1.5)
For LONG: Stop = Entry - Stop_Distance
For SHORT: Stop = Entry + Stop_Distance
The stop is placed 1.5 ATRs away from entry by default, adapting automatically to instrument volatility.
Target Calculation:
Target_Distance = Stop_Distance × Risk_Reward_Ratio (default 2.0)
For LONG: Target = Entry + Target_Distance
For SHORT: Target = Entry - Target_Distance
Default 2:1 risk/reward means target is twice as far as stop.
Example:
• Price: $100
• ATR: $2
• ATR Multiplier: 1.5
• Risk/Reward: 2.0
LONG Signal:
• Entry: $100
• Stop: $100 - ($2 × 1.5) = $97.00 (-$3 risk)
• Target: $100 + ($3 × 2.0) = $106.00 (+$6 reward)
• Risk/Reward: $3 risk for $6 reward = 1:2 ratio
Target/Stop Box Lifecycle:
Boxes persist for a lifetime (default 20 bars) OR until an opposite signal fires, whichever comes first. This provides visual reference for active trade levels without permanent chart clutter.
When a new opposite-direction signal appears, all existing boxes from the previous direction are immediately deleted, ensuring only relevant levels remain visible.
Adaptive Stop/Target Sizing:
While not explicitly coded in the current version, the shadow portfolio tracking system calculates PnL based on these levels. Users can observe which ATR multipliers and risk/reward ratios produce optimal results for their instrument/timeframe via the dashboard performance metrics.
📊 COMPREHENSIVE VISUAL SYSTEM
KMD provides rich visual feedback through four distinct layers:
1. PROBABILITY CLOUD (Adaptive Volatility Bands):
Two sets of bands around price that expand/contract with MMD:
Calculation:
Std_Multiplier = 1 + MMD × 3
Upper_1σ = Close + ATR × Std_Multiplier × 0.5
Lower_1σ = Close - ATR × Std_Multiplier × 0.5
Upper_2σ = Close + ATR × Std_Multiplier
Lower_2σ = Close - ATR × Std_Multiplier
• Inner band (±0.5× adjusted ATR) : 68% probability zone (1 standard deviation equivalent)
• Outer band (±1.0× adjusted ATR) : 95% probability zone (2 standard deviation equivalent)
When MMD spikes, bands widen dramatically, showing increased uncertainty. When MMD calms, bands tighten, showing normal price action.
2. MOMENTUM FLOW VECTORS (Directional Arrows):
Dynamic arrows that visualize momentum strength and direction:
Arrow Properties:
• Length: Proportional to momentum magnitude (2-10 bars forward)
• Width: 1px (weak), 2px (medium), 3px (strong)
• Transparency: 30-100 (more opaque = stronger momentum)
• Direction: Up for bullish, down for bearish
• Placement: Below bars (bulls) or above bars (bears)
Trigger Logic:
• Always appears every 5 bars (regular sampling)
• Forced appearance if momentum strength > 50 OR regime shift OR MMD velocity > 10%
Strong momentum (>75%) gets:
• Secondary support arrow (70% length, lighter color)
• Label showing "75%" strength
Very strong momentum (>60%) gets:
• Gradient flow lines (thick vertical lines showing momentum vector)
This creates a dynamic "flow field" showing where market pressure is pushing price.
3. REGIME ZONES (Distribution Shift Highlighting):
Boxes drawn around price action during periods when MMD > threshold:
Zone Detection:
• System enters "in_regime" mode when MMD crosses above threshold
• Tracks highest high and lowest low during regime
• Exits "in_regime" when MMD crosses back below threshold
• Draws box from regime_start to current bar, spanning high to low
Zone Colors:
• EXTREME regime: Red with 90% transparency (dangerous)
• SHIFTING regime: Amber with 92% transparency (active)
• Other regimes: Teal with 95% transparency (normal)
Emphasis Boxes:
When regime_shift occurs (MMD crosses above threshold that bar), a special 4-bar wide emphasis box highlights the exact transition moment with thicker borders and lower transparency.
This visual immediately shows "the market just changed" moments.
4. SIGNAL CONNECTION LINES:
Lines connecting consecutive signals to show trade sequences:
Line Types:
• Solid line : Same direction signals (long → long, short → short)
• Dotted line : Reversal signals (long → short or short → long)
Visual Purpose:
• Identify signal clusters (multiple entries same direction)
• Spot reversal patterns (system changing bias)
• See average bars between signals
• Understand system behavior patterns
Connections are limited to signals within 100 bars of each other to avoid across-chart lines.
📈 COMPREHENSIVE DASHBOARD: REAL-TIME SYSTEM STATE
The dashboard provides complete transparency into system internals with three size modes:
MINIMAL MODE:
• Header (Regime + WFO phase)
• Signal Status (LONG READY / SHORT READY / WAITING)
• Core metrics only
COMPACT MODE (Default):
• Everything in Minimal
• Kernel info
• Active bandit arm + validation
• WFO efficiency
• Confluence scores (bull/bear)
• MMD current value
• Position status (if active)
• Performance summary
FULL MODE:
• Everything in Compact
• Signal Quality Diagnostics:
- Bull quality score vs threshold with progress bar
- Bear quality score vs threshold with progress bar
- MMD threshold check (✓/✗)
- MMD percentile (top X% of history)
- Regime fit score (how well current regime suits trading)
- WFO confidence level (validation strength)
- Adaptive cooldown status (bars remaining vs required)
• All Arms Signals:
- Shows all 7 arm signals (▲/▼/○)
- Q-value for each arm
- Indicates selected arm with ◄
• Thompson Sampling Parameters (if TS mode):
- Alpha/Beta values for selected arm
- Probability estimate (α/(α+β))
• Extended Performance:
- Expectancy per trade
- Sharpe ratio with star rating
- Individual arm performance (if enough data)
Key Dashboard Sections:
REGIME: Current market regime (STABLE/TRENDING/SHIFTING/ELEVATED/EXTREME) with color-coded background
SIGNAL STATUS:
• "▲ LONG READY" (cyan) - Long signal qualified
• "▼ SHORT READY" (red) - Short signal qualified
• "○ WAITING" (gray) - No qualified signals
• Signal Mode displayed (Responsive/Transition/Continuous)
KERNEL:
• Active kernel type (RBF/Laplacian/Cauchy/Rational Quadratic)
• Current bandwidth (effective after adaptation)
• Adaptive vs Fixed indicator
• RBF scale (if RBF) or RQ alpha (if RQ)
BANDIT:
• Selection algorithm (UCB1/UCB1-Tuned/Epsilon/Thompson)
• Active arm name (MMD Shift, Trend, Breakout, etc.)
• Validation status (✓ if validated, ? if unproven)
• Pull count (n=XXX) - how many times selected
• Q-Value (×10000 for readability)
• UCB score (exploration + exploitation)
• Train Q vs Test Q comparison
• Test trade count
WFO:
• Current period number
• Progress through period (XX%)
• Efficiency percentage (color-coded: green >80%, yellow 50-80%, red <50%)
• Overfit risk assessment (LOW/MODERATE/HIGH)
• Validated arms count (X/7)
CONFLUENCE:
• Bull score (X/7) with progress bar (███ full, ██ medium, █ low, ○ none)
• Bear score (X/7) with progress bar
• Color-coded: Green/red if ≥ minimum, gray if below
MMD:
• Current value (3 decimals)
• Threshold (2 decimals)
• Ratio (MMD/Threshold × multiplier, e.g. "1.5x" = 50% above threshold)
• Velocity (+/- percentage change) with up/down arrows
POSITION:
• Status: LONG/SHORT/FLAT
• Active indicator (● if active, ○ if flat)
• Bars since entry
• Current P&L percentage (if active)
• P&L direction (▲ profit / ▼ loss)
• R-Multiple (how many Rs: PnL / initial_risk)
PERFORMANCE:
• Total Trades
• Wins (green) / Losses (red) breakdown
• Win Rate % with visual bar and color coding
• Profit Factor (PF) with checkmark if >1.0
• Expectancy % (average profit per trade)
• Sharpe Ratio with star rating (★★★ >2, ★★ >1, ★ >0, ○ negative)
• Max DD % (maximum drawdown) with "Now: X%" showing current drawdown
🔧 KEY PARAMETERS EXPLAINED
Kernel Configuration:
• Kernel Function : RBF / Laplacian / Cauchy / Rational Quadratic
- Start with Cauchy for stability, experiment with others
• Bandwidth (σ) (0.5-10.0, default 2.0): Kernel sensitivity
- Lower: More signals, more false positives (scalping: 0.8-1.5)
- Medium: Balanced (swing: 1.5-3.0)
- Higher: Fewer signals, stronger quality (position: 3.0-8.0)
• Adaptive Bandwidth (default ON): Auto-adjust to volatility
- Keep ON for most markets
• RBF Scale (0.1-2.0, default 0.5): RBF-specific scaling
- Only matters if RBF kernel selected
- Lower = more sensitive (0.3 for scalping)
- Higher = less sensitive (1.0+ for position)
• RQ Alpha (0.5-5.0, default 2.0): Rational Quadratic tail behavior
- Only matters if RQ kernel selected
- Low (0.5-1.0): Heavy tails, robust to outliers (like Cauchy)
- High (3.0-5.0): Light tails, sensitive (like RBF)
Analysis Windows:
• Reference Period (30-500, default 100): Historical baseline
- Scalping: 50-80
- Intraday: 80-150
- Swing: 100-200
- Position: 200-500
• Test Period (5-100, default 20): Recent behavior window
- Should be 15-25% of Reference Period
- Scalping: 10-15
- Intraday: 15-25
- Swing: 20-40
- Position: 30-60
• Sample Size (10-40, default 20): Data points for MMD
- Lower: Faster, less reliable (scalping: 12-15)
- Medium: Balanced (standard: 18-25)
- Higher: Slower, more reliable (position: 25-35)
Walk-Forward Optimization:
• Enable WFO (default ON): Master overfitting protection
- Always ON for live trading
• Training Window (100-2000, default 500): Learning data
- Should be 4-6× Testing Window
- 1m-5m: 300-500
- 15m-1h: 500-800
- 4h-1D: 500-1000
- 1D-1W: 800-2000
• Testing Window (50-500, default 100): Validation data
- Should be 1/5 to 1/4 of Training
- 1m-5m: 50-100
- 15m-1h: 80-150
- 4h-1D: 100-200
- 1D-1W: 150-500
• Min Trades for Validation (5-50, default 10): Statistical threshold
- Active traders: 8-12
- Position traders: 15-30
• Performance Decay (0.8-0.99, default 0.95): Old data forgetting
- Aggressive: 0.85-0.90 (volatile markets)
- Moderate: 0.92-0.96 (most use cases)
- Conservative: 0.97-0.99 (stable markets)
Multi-Armed Bandit:
• Learning Rate (α) (0.01-0.3, default 0.08): Adaptation speed
- Low: 0.01-0.05 (position trading, stable)
- Medium: 0.06-0.12 (day/swing trading)
- High: 0.15-0.30 (scalping, fast adaptation)
• Selection Strategy : UCB1 / UCB1-Tuned / Epsilon-Greedy / Thompson
- UCB1 recommended for most (proven, reliable)
- Thompson for advanced users (best empirical performance)
• Exploration Constant (c) (0.5-3.0, default 1.5): Explore vs exploit
- Low: 0.5-1.0 (conservative, proven strategies)
- Medium: 1.2-1.8 (balanced)
- High: 2.0-3.0 (experimental, volatile markets)
• Epsilon (0.0-0.3, default 0.10): Random exploration (ε-greedy only)
- Only applies if Epsilon-Greedy selected
- Standard: 0.10 (10% random)
Signal Configuration:
• MMD Threshold (0.05-1.0, default 0.15): Distribution divergence trigger
- Low: 0.08-0.12 (scalping, sensitive)
- Medium: 0.12-0.20 (day/swing)
- High: 0.25-0.50 (position, strong signals)
- Stocks/indices: 0.12-0.18
- Forex: 0.15-0.25
- Crypto: 0.20-0.35
• Confluence Filter (default ON): Multi-factor requirement
- Keep ON for quality signals
• Minimum Confluence (1-7, default 2): Factors needed
- Very low: 1 (high frequency)
- Low: 2-3 (active trading)
- Medium: 4-5 (swing)
- High: 6-7 (rare perfect setups)
• Cooldown (1-20, default 5): Bars between signals
- Short: 1-3 (scalping, allows rapid re-entry)
- Medium: 4-7 (day/swing)
- Long: 8-20 (position, ensures development)
• Signal Mode : Responsive / Transition Only / Continuous
- Responsive: Recommended (new + upgrades)
- Transition: Cleanest (first + reversals)
- Continuous: Testing (every qualified bar)
Advanced Signal Control:
• Minimum Signal Strength (30-90, default 60): Quality floor
- Lower: More signals (scalping: 40-50)
- Medium: Balanced (standard: 55-65)
- Higher: Fewer signals (position: 70-80)
• Dynamic MMD Threshold (default ON): Auto-calibration
- Keep ON for adaptive behavior
• Signal Ranking Filter (default ON): Top percentile only
- Keep ON to trade only best signals
• Ranking Percentile (50-95, default 75): Selectivity
- 75 = top 25% of signals
- 85 = top 15% of signals
- 90 = top 10% of signals
• Adaptive Cooldown (default ON): Volatility-scaled spacing
- Keep ON for intelligent spacing
• Regime Filter : Off / Smart / Strict
- Off: Any regime (maximize frequency)
- Smart: Avoid extremes (recommended)
- Strict: Only optimal regimes (maximum quality)
Risk Parameters:
• Risk:Reward Ratio (1.0-5.0, default 2.0): Target distance multiplier
- Conservative: 1.0-1.5 (higher WR needed)
- Balanced: 2.0-2.5 (standard professional)
- Aggressive: 3.0-5.0 (lower WR acceptable)
• Stop Loss (ATR mult) (0.5-4.0, default 1.5): Stop distance
- Tight: 0.5-1.0 (scalping, low vol)
- Medium: 1.2-2.0 (day/swing)
- Wide: 2.5-4.0 (position, high vol)
• Pause After Drawdown (2-20%, default 8%): Circuit breaker
- Aggressive: 3-6% (small accounts)
- Moderate: 6-10% (most traders)
- Relaxed: 10-15% (large accounts)
Multi-Timeframe:
• MTF Confirmation (default OFF): Higher TF filter
- Turn ON for swing/position trading
- Keep OFF for scalping/day trading
• Higher Timeframe (default "60"): HTF for trend check
- Should be 3-5× chart timeframe
- 1m chart → 5m or 15m
- 5m chart → 15m or 60m
- 15m chart → 60m or 240m
- 1h chart → 240m or D
Display:
• Probability Cloud (default ON): Volatility bands
• Momentum Flow Vectors (default ON): Directional arrows
• Regime Zones (default ON): Distribution shift boxes
• Signal Connections (default ON): Lines between signals
• Dashboard (default ON): Stats table
• Dashboard Position : Top Left / Top Right / Bottom Left / Bottom Right
• Dashboard Size : Minimal / Compact / Full
• Color Scheme : Default / Monochrome / Warm / Cool
• Show MMD Debug Plot (default OFF): Overlay MMD value
- Turn ON temporarily for threshold calibration
🎓 PROFESSIONAL USAGE PROTOCOL
Phase 1: Parameter Calibration (Week 1)
Goal: Find optimal kernel and bandwidth for your instrument/timeframe
Setup:
• Enable "Show MMD Debug Plot"
• Start with Cauchy kernel, 2.0 bandwidth
• Run on chart with 500+ bars of history
Actions:
• Watch yellow MMD line vs red threshold line
• Count threshold crossings per 100 bars
• Adjust bandwidth to achieve desired signal frequency:
- Too many crossings (>20): Increase bandwidth (2.5-3.5)
- Too few crossings (<5): Decrease bandwidth (1.2-1.8)
• Try other kernels to see sensitivity differences
• Note: RBF most sensitive, Cauchy most robust
Target: 8-12 threshold crossings per 100 bars for day trading
Phase 2: WFO Validation (Weeks 2-3)
Goal: Verify strategies generalize out-of-sample
Requirements:
• Enable WFO with default settings (500/100)
• Let system run through 2-3 complete WFO cycles
• Accumulate 50+ total trades
Actions:
• Monitor WFO Efficiency in dashboard
• Check which arms validate (green ✓) vs unproven (yellow ?)
• Review Train Q vs Test Q for selected arm
• If efficiency < 0.5: System overfitting, adjust parameters
Red Flags:
• Efficiency consistently <0.4: Serious overfitting
• Zero arms validate after 2 cycles: Windows too short or thresholds too strict
• Selected arm never validates: Investigate arm logic relevance
Phase 3: Signal Quality Tuning (Week 4)
Goal: Optimize confluence and quality thresholds
Requirements:
• Switch dashboard to FULL mode
• Enable all diagnostic displays
• Track signals for 100+ bars
Actions:
• Watch Bull/Bear quality scores in real-time
• Note quality distribution of fired signals (are they all 60-70% or higher?)
• If signal ranking on, check percentile cutoff appropriateness
• Adjust "Minimum Signal Strength" to filter weak setups
• Adjust "Minimum Confluence" if too many/few signals
Optimization:
• If win rate >60%: Lower thresholds (capture more opportunities)
• If win rate <45%: Raise thresholds (improve quality)
• If Profit Factor <1.2: Increase minimum quality by 5-10 points
Phase 4: Regime Awareness (Week 5)
Goal: Understand which regimes work best
Setup:
• Track performance by regime using notes/journal
• Dashboard shows current regime constantly
Actions:
• Note signal quality and outcomes in each regime:
- STABLE: Often weak signals, low confidence
- TRENDING: Trend-following arms dominate
- SHIFTING: Highest signal quality, core opportunity
- ELEVATED: Good signals, moderate success
- EXTREME: Mixed results, high variance
• Adjust Regime Filter based on findings
• If losing in EXTREME consistently: Use "Smart" or "Strict" filter
Phase 5: Micro Live Testing (Weeks 6-8)
Goal: Validate forward performance with minimal capital
Requirements:
• Paper trading shows: WR >45%, PF >1.2, Efficiency >0.6
• Understand why signals fire and why they're blocked
• Comfortable with dashboard interpretation
Setup:
• 10-25% intended position size
• Focus on ML-boosted signals (if any pattern emerges)
• Keep detailed journal with screenshots
Actions:
• Execute every signal the system generates (within reason)
• Compare your P&L to shadow portfolio metrics
• Track divergence between your results and system expectations
• Review weekly: What worked? What failed? Any execution issues?
Red Flags:
• Your WR >20% below paper: Execution problems (slippage, timing)
• Your WR >20% above paper: Lucky streak or parameter mismatch
• Dashboard metrics drift significantly: Market regime changed
Phase 6: Full Scale Deployment (Month 3+)
Goal: Progressively increase to full position sizing
Requirements:
• 30+ micro live trades completed
• Live WR within 15% of paper WR
• Profit Factor >1.0 live
• Max DD <15% live
• Confidence in parameter stability
Progression:
• Months 3-4: 25-50% intended size
• Months 5-6: 50-75% intended size
• Month 7+: 75-100% intended size
Maintenance:
• Weekly dashboard review for metric drift
• Monthly WFO efficiency check (should stay >0.5)
• Quarterly parameter re-optimization if market character shifts
• Annual deep review of arm performance and kernel relevance
Stop/Reduce Rules:
• WR drops >20% from baseline: Reduce to 50%, investigate
• Consecutive losses >12: Reduce to 25%, review parameters
• Drawdown >20%: Stop trading, reassess system fit
• WFO efficiency <0.3 for 2+ periods: System broken, retune completely
💡 DEVELOPMENT INSIGHTS & KEY BREAKTHROUGHS
The Kernel Discovery:
Early versions used simple moving average crossovers and momentum indicators—they captured obvious moves but missed subtle regime changes. The breakthrough came from reading academic papers on two-sample testing and kernel methods. Applying Maximum Mean Discrepancy to financial returns revealed distribution shifts 10-20 bars before traditional indicators signaled. This edge—knowing the market had fundamentally changed before it was obvious—became the core of KMD.
Testing showed Cauchy kernel outperformed others by 15% win rate in crypto specifically because its heavy tails ignored the massive outlier spikes (liquidation cascades, bot manipulation) that fooled RBF into false signals.
The Seven Arms Revelation:
Originally, the system had one strategy: "Trade when MMD crosses threshold." Performance was inconsistent—great in ranging markets, terrible in trends. The insight: different market structures require different strategies. Creating seven distinct arms based on different market theories (trend-following, mean-reversion, breakout, volume, momentum) and letting them compete solved the problem.
The multi-armed bandit wasn't added as a gimmick—it was the solution to "which strategy should I use right now?" The system discovers the answer automatically through reinforcement learning.
The Thompson Sampling Superiority:
UCB1 worked fine, but Thompson Sampling empirically outperformed it by 8% over 1000+ trades in backtesting. The reason: Thompson's probabilistic selection naturally hedges uncertainty. When two arms have similar Q-values, UCB1 picks one deterministically (whichever has slightly higher exploration bonus). Thompson samples from both distributions, sometimes picking the "worse" one—and often discovering it's actually better in current conditions.
Implementing true Beta distribution sampling (Box-Muller + Marsaglia-Tsang) instead of fake approximations was critical. Fake Thompson (using random with bias) underperformed UCB1. Real Thompson with proper Bayesian updating dominated.
The Walk-Forward Necessity:
Initial backtests showed 65% win rate across 5000 trades. Live trading: 38% win rate over first 100 trades. Crushing disappointment. The problem: overfitting. The training data included the test data (look-ahead bias). Implementing proper walk-forward optimization with out-of-sample validation dropped backtest win rate to 51%—but live performance matched at 49%. That's a system you can trust.
WFO efficiency metric became the North Star. If efficiency >0.7, live results track paper. If efficiency <0.5, prepare for disappointment.
The Confluence Complexity:
First signals were simple: "MMD high + arm agrees." This generated 200+ signals on 1000 bars with 42% win rate—not tradeable. Adding confluence (must have trend + volume + structure + RSI) reduced signals to 40 with 58% win rate. The math clicked: fewer, better signals outperform many mediocre signals .
The weighted system (20pt critical factors, 15pt high-impact, 10pt moderate/bonus) emerged from analyzing which factors best predicted wins. Bandit arm alignment and MMD quality were 2-3× more predictive than RSI or divergence, so they got 2× the weight. This isn't arbitrary—it's data-driven.
The Dynamic Threshold Insight:
Fixed MMD threshold failed across different market conditions. 0.15 worked perfectly on ES but fired constantly on Bitcoin. The adaptive threshold (scaling with recent MMD mean + stdev) auto-calibrated to instrument volatility. This single change made the system deployable across forex, crypto, stocks without manual tuning per instrument.
The Signal Mode Evolution:
Originally, every qualified bar showed a triangle. Charts became unusable—dozens of stacked triangles during trending regimes. "Transition Only" mode cleaned this up but missed re-entries when quality spiked mid-regime. "Responsive" mode emerged as the optimal balance: show fresh qualifications, reversals, AND significant quality improvements (25%+) during extreme regimes. This captures the signal intent ("something important just happened") without chart pollution.
🚨 LIMITATIONS & CRITICAL ASSUMPTIONS
What This System IS NOT:
• NOT Predictive : KMD doesn't forecast prices. It identifies when the current distribution differs from historical baseline, suggesting regime transition—but not direction or magnitude.
• NOT Holy Grail : Typical performance is 48-56% win rate with 1.3-1.8 avg R-multiple. This is a probabilistic edge, not certainty. Expect losing streaks of 8-12 trades.
• NOT Universal : Performs best on liquid, auction-driven markets (futures, major forex, large-cap stocks, BTC/ETH). Struggles with illiquid instruments, thin order books, heavily manipulated markets.
• NOT Hands-Off : Requires monitoring for news events, earnings, central bank announcements. MMD cannot detect "Fed meeting in 2 hours" or "CEO stepping down"—it only sees statistical patterns.
• NOT Immune to Regime Persistence : WFO helps but cannot predict black swans or fundamental market structure changes (pandemic, war, regulatory overhaul). During these events, all historical patterns may break.
Core Assumptions:
1. Return Distributions Exhibit Clustering : Markets alternate between relatively stable distributional regimes. Violation: Permanent random walk, no regime structure.
2. Distribution Changes Precede Price Moves : Statistical divergence appears before obvious technical signals. Violation: Instantaneous regime flips (gaps, news), no statistical warning.
3. Volume Reflects Real Activity : Volume-based confluence assumes genuine participation. Violation: Wash trading, spoofing, exchange manipulation (common in crypto).
4. Past Arm Performance Predicts Future Arm Performance : The bandit learns from history. Violation: Fundamental strategy regime change (e.g., market transitions from mean-reverting to trending permanently).
5. ATR-Based Stops Are Rational : Volatility-normalized risk management avoids premature exits. Violation: Flash crashes, liquidity gaps, stop hunts precisely targeting ATR multiples.
6. Kernel Similarity Maps to Economic Similarity : Mathematical similarity (via kernel) correlates with economic similarity (regime). Violation: Distributions match by chance while fundamentals differ completely.
Performs Best On:
• ES, NQ, RTY (S&P 500, Nasdaq, Russell 2000 futures)
• Major forex pairs: EUR/USD, GBP/USD, USD/JPY, AUD/USD
• Liquid commodities: CL (crude oil), GC (gold), SI (silver)
• Large-cap stocks: AAPL, MSFT, GOOGL, TSLA (>$10M avg daily volume)
• Major crypto on reputable exchanges: BTC, ETH (Coinbase, Kraken)
Performs Poorly On:
• Low-volume stocks (<$1M daily volume)
• Exotic forex pairs with erratic spreads
• Illiquid crypto altcoins (manipulation, unreliable volume)
• Pre-market/after-hours (thin liquidity, gaps)
• Instruments with frequent corporate actions (splits, dividends)
• Markets with persistent one-sided intervention (central bank pegs)
Known Weaknesses:
• Lag During Instantaneous Shifts : MMD requires (test_window) bars to detect regime change. Fast-moving events (5-10 bar crashes) may bypass detection entirely.
• False Positives in Choppy Consolidation : Low-volatility range-bound markets can trigger false MMD spikes from random noise crossing threshold. Regime filter helps but doesn't eliminate.
• Parameter Sensitivity : Small bandwidth changes (2.0→2.5) can alter signal frequency by 30-50%. Requires careful calibration per instrument.
• Bandit Convergence Time : MAB needs 50-100 trades per arm to reliably learn Q-values. Early trades (first 200 bars) are essentially random exploration.
• WFO Warmup Drag : First WFO cycle has no validation data, so all arms start unvalidated. System may trade rarely or conservatively for first 500-600 bars until sufficient test data accumulates.
• Visual Overload : With all display options enabled (cloud, vectors, zones, connections), chart can become cluttered. Disable selectively for cleaner view.
⚠️ RISK DISCLOSURE
Trading futures, forex, stocks, options, and cryptocurrencies involves substantial risk of loss and is not suitable for all investors. Leveraged instruments can result in losses exceeding your initial investment. Past performance, whether backtested or live, is not indicative of future results.
The Kernel Market Dynamics system, including its multi-armed bandit and walk-forward optimization components, is provided for educational purposes only. It is not financial advice, investment advice, or a recommendation to buy or sell any security or instrument.
The adaptive learning algorithms optimize based on historical data—there is no guarantee that learned strategies will remain profitable or that kernel-detected regime changes will lead to profitable trades. Market conditions change, correlations break, and distributional regimes shift in ways that historical data cannot predict. Black swan events occur.
Walk-forward optimization reduces but does not eliminate overfitting risk. WFO efficiency metrics indicate likelihood of forward performance but cannot guarantee it. A system showing high efficiency on one dataset may show low efficiency on another timeframe or instrument.
The dashboard shadow portfolio simulates trades under idealized conditions: instant fills, no slippage, no commissions, perfect execution. Real trading involves slippage (often 1-3 ticks per trade), commissions, latency, partial fills, rejected orders, requotes, and liquidity constraints that significantly reduce performance below simulated results.
Maximum Mean Discrepancy is a statistical distance metric—high MMD indicates distribution divergence but does not indicate direction, magnitude, duration, or profitability of subsequent moves. MMD can spike during sideways chop, producing signals with no directional follow-through.
Users must independently validate system performance on their specific instruments, timeframes, broker execution, and market conditions before risking capital. Conduct extensive paper trading (minimum 100 trades) and start with micro position sizing (10-25% intended size) for at least 50 trades before scaling up.
Never risk more capital than you can afford to lose completely. Use proper position sizing (1-2% risk per trade maximum). Implement stop losses on every trade. Maintain adequate margin/capital reserves. Understand that most retail traders lose money. Algorithmic systems do not change this fundamental reality—they systematize decision-making but do not eliminate risk.
The developer makes no warranties regarding profitability, suitability, accuracy, reliability, or fitness for any particular purpose. Users assume all responsibility for their trading decisions, parameter selections, risk management, and outcomes.
By using this indicator, you acknowledge that you have read and understood these risk disclosures and accept full responsibility for all trading activity and potential losses.
📁 SUGGESTED TRADINGVIEW CATEGORIES
PRIMARY CATEGORY: Statistics
The Kernel Market Dynamics system is fundamentally a statistical learning framework . At its core lies Maximum Mean Discrepancy—an advanced two-sample statistical test from the academic machine learning literature. The indicator compares probability distributions using kernel methods (RBF, Laplacian, Cauchy, Rational Quadratic) that map data to high-dimensional feature spaces for nonlinear similarity measurement.
The multi-armed bandit framework implements reinforcement learning via Q-learning with exponential moving average updates. Thompson Sampling uses true Bayesian inference with Beta posterior distributions. Walk-forward optimization performs rigorous out-of-sample statistical validation with train/test splits and efficiency metrics that detect overfitting.
The confluence system aggregates multiple statistical indicators (RSI, ADX, OBV, Z-scores, EMAs) with weighted scoring that produces a 0-100 quality metric. Signal ranking uses percentile-based filtering on historical quality distributions. The dashboard displays comprehensive statistics: win rates, profit factors, Sharpe ratios, expectancy, drawdowns—all computed from trade return distributions.
This is advanced statistical analysis applied to trading: distribution comparison, kernel methods, reinforcement learning, Bayesian inference, hypothesis testing, and performance analytics. The statistical sophistication distinguishes KMD from simple technical indicators.
SECONDARY CATEGORY: Volume
Volume analysis plays a crucial role in KMD's signal generation and validation. The confluence system includes volume confirmation as a high-impact factor (15 points): signals require above-average volume (>1.2× mean) for full points, with scaling based on volume ratio. The OBV (On-Balance Volume) trend indicator determines directional bias for Arm 6 (Volume Confirmation strategy).
Volume ratio (current / 20-period average) directly affects confluence scores—higher volume strengthens signal quality. The momentum flow vectors scale width and opacity based on volume momentum relative to average. Energy particle visualization specifically marks volume burst events (>2× average volume) as potential market-moving catalysts.
Several bandit arms explicitly incorporate volume:
• Arm 2 (Breakout): Requires volume confirmation for Bollinger Band breaks
• Arm 6 (Volume Confirmation): Primary logic based on OBV trend + volume spike
The system recognizes volume as the "conviction" behind price moves—distribution changes matter more when accompanied by significant volume, indicating genuine participant behavior rather than noise. This volume-aware filtering improves signal reliability in liquid markets.
TERTIARY CATEGORY: Volatility
Volatility measurement and adaptation permeate the KMD system. ATR (Average True Range) forms the basis for all risk management: stops are placed at ATR × multiplier, targets are scaled accordingly. The adaptive bandwidth feature scales kernel bandwidth (0.5-2.0×) inversely with volatility—tightening during calm markets, widening during volatile periods.
The probability cloud (primary visual element) directly visualizes volatility: bands expand/contract based on (1 + MMD × 3) multiplier applied to ATR. Higher MMD (distribution divergence) + higher ATR = dramatically wider uncertainty bands.
Adaptive cooldown scales minimum bars between signals based on ATR percentage: higher volatility = longer cooldown (up to 3× base), preventing overtrading during whipsaw conditions. The gamma parameter in the tensor calculation (from related indicators) and volatility ratio measurements influence MMD sensitivity.
Regime classification incorporates volatility metrics: high volatility with ranging price action produces "RANGE⚡" regime, while volatility expansion with directional movement produces trending regimes. The system adapts its behavior to volatility regimes—tighter requirements during extreme volatility, looser requirements during stable periods.
ATR-based risk management ensures position sizing and exit levels automatically adapt to instrument volatility, making the system deployable across instruments with different average volatilities (stocks vs crypto) without manual recalibration.
═══════════════════════════════════════════════════════
CLOSING STATEMENT
═══════════════════════════════════════════════════════
Kernel Market Dynamics doesn't just measure price—it measures the probability structure underlying price. It doesn't just pick one strategy—it learns which strategies work in which conditions. It doesn't just optimize on history—it validates on the future.
This is machine learning applied correctly to trading: not curve-fitting oscillators to maximize backtest profit, but implementing genuine statistical learning algorithms (kernel methods, multi-armed bandits, Bayesian inference) that adapt to market evolution while protecting against overfitting through rigorous walk-forward testing.
The seven arms compete. The Thompson sampler selects. The kernel measures. The confluence scores. The walk-forward validates. The signals fire.
Most indicators tell you what happened. KMD tells you when the game changed.
"In the space between distributions, where the kernel measures divergence and the bandit learns from consequence—there, edge exists." — KMD-WFO-MAB
Taking you to school. — Dskyz, Trade with insight. Trade with anticipation.
Crypto Correlation Oscillator# Crypto Correlation Oscillator
**Companion indicator for Tri-Align Crypto Trend**
## Overview
The Crypto Correlation Oscillator helps you identify **alpha opportunities** and **market regime changes** by showing how closely your coin follows Bitcoin and other assets over time. It displays rolling correlations as an oscillator in a separate pane below your price chart.
## What It Does
This indicator calculates **Pearson correlations** between different trading pairs on a rolling window (default: 100 bars). Correlations range from **-1.0** (perfect inverse relationship) to **+1.0** (perfect positive relationship), with **0** meaning no correlation.
### The 5 Correlation Lines
1. **Blue (thick line) - Coin vs BTC**: The most important metric
- **High correlation (>0.7)**: Your coin is just following BTC - no independent movement
- **Low correlation (<0.3)**: Your coin has **alpha** - it's moving independently from BTC
- **Negative correlation**: Your coin moves opposite to BTC (rare but powerful)
2. **Purple - Coin/BTC vs BTC**: Inverse relationship check
- **Negative values**: When BTC rises, your coin weakens relative to BTC
- **Positive values**: When BTC rises, your coin strengthens against BTC
3. **Orange - Coin vs Coin/BTC**: Structural consistency check
- Shows how well the Coin/USDT and Coin/BTC pairs maintain their mathematical relationship
- Unusual values can indicate liquidity issues or market inefficiencies
4. **Light Red - Coin vs USDT.D** (optional): Stablecoin dominance correlation
- Shows how your coin correlates with USDT dominance
- Useful for understanding flight-to-safety dynamics
5. **Light Green - Coin vs BTC.D** (optional): Bitcoin dominance correlation
- Shows how your coin correlates with BTC dominance
- Helps identify altcoin season vs BTC dominance cycles
## How to Read It
### Finding Alpha Opportunities
- **Low blue line (<0.3)**: Your coin is decoupled from BTC → potential alpha
- **Blue line dropping**: Coin is gaining independence from BTC
- **Blue line spiking to >0.9**: Coin is a "BTC clone" with no independent movement
### Regime Change Detection
- **Blue line crossing 0.5**: Major shift in correlation behavior
- **Purple line turning negative**: Coin starting to weaken when BTC rises (warning sign)
- **Sharp correlation changes**: Market structure is shifting - adjust strategy
### Visual Zones
- **Blue background**: High correlation zone (>0.7) - coin just following BTC
- **Red background**: Inverse correlation zone (<-0.5) - coin moving opposite to BTC
### Reference Lines
- **+1.0 / -1.0**: Perfect correlation boundaries (dotted gray)
- **+0.5 / -0.5**: Moderate correlation thresholds (dotted gray)
- **0.0**: Zero correlation line (solid gray)
## Dynamic Legend
The legend table (top-right) automatically shows the actual symbol names based on your chart:
- **Example on SOLUSDT**: Shows "SOL vs BTC", "SOL/BTC vs BTC", "SOL vs SOL/BTC", etc.
- **Color boxes**: Match the plot colors for easy identification
- **Live values**: Current correlation numbers update in real-time
- **Tooltips**: Hover over labels for interpretation guidance
## Configuration
### Key Inputs
- **Correlation Lookback** (default: 100): Number of bars for rolling correlation window
- Shorter = more reactive, noisier
- Longer = smoother, slower to detect changes
- **Correlation Smoothing** (default: 5): EMA smoothing period for raw correlations
- Reduces noise while preserving trends
- **Symbol Detection**: Auto-detects symbols from your chart, or use manual overrides
- **Dominance Pairs**: Toggle USDT.D and BTC.D correlations on/off
## Usage Tips
1. **Combine with main Tri-Align indicator**: Use correlation for context, Tri-Align for entry/exit signals
2. **Watch for divergences**: Correlation changing while price moves in sync can signal upcoming shift
3. **Adjust lookback period**: Use shorter (50-70) for day trading, longer (150-200) for position trading
4. **Focus on the blue line**: It's your primary alpha indicator
## Technical Details
- **Calculation**: Pearson correlation coefficient with EMA smoothing
- **Data source**: Close prices from `request.security()` (multi-timeframe capable)
- **Update frequency**: Every bar on your selected timeframe
- **Overlay**: False (displays in separate pane)
## Quick Interpretation Guide
| Blue Line Value | Interpretation | Action |
|----------------|----------------|--------|
| > 0.9 | Coin is a BTC clone | Avoid - no alpha opportunity |
| 0.7 - 0.9 | High correlation | Standard altcoin behavior |
| 0.3 - 0.7 | Moderate correlation | Some independence emerging |
| < 0.3 | Low correlation | **Strong alpha opportunity** |
| < 0 | Inverse correlation | Rare - potential hedge asset |
| Purple Line | Interpretation |
|-------------|----------------|
| Strongly negative | Coin weakens when BTC rises - risky |
| Near zero | Coin/BTC pair moves independently of BTC |
| Positive | Coin strengthens with BTC - ideal |
## Version History
### v1.0 (Initial Release)
- Pearson correlation calculation with configurable lookback
- 5 correlation pairs: Coin vs BTC, Coin/BTC vs BTC, Coin vs Coin/BTC, USDT.D, BTC.D
- EMA smoothing to reduce noise
- Visual zones for high/inverse correlation
- Dynamic legend with symbol name extraction
- Auto-symbol detection matching main Tri-Align indicator
Other alts compensated capitalization [Peregringlk]DISCLAIMER: I'm not a native English speaker, so let me know please about mistakes in my wording.
Introduction
==========
This indicator (the middle one in the image) shows how the "others altcoins" (all altcoins except coins with high capitalization) are adding own value to its capitalization by removing BTC price changes. By "own value" I mean USD value gaining by actual buys in BTC markets beyong arbitrage effects of BTC price changes.
The main idea is that, if bitcoin has increased is value by 20%, and the other altcoins has increased its capitalization by 30%, the chart will only plot an increased of 10%. In other words, it will show its increased capitalization measured in BTC (the combined altcoin/BTC market is uptrending). Its purpose is to try to identify altseasons. A bit more concisely, the graph will only grow when both USD and BTC capitalization are growing. If any of them are going down, the graph will go down as well.
Rationale
========
- Altseasons are characterized by an incresed in BTC value of almost every altcoin during some period of time, although not all at once, but distributed over the altseason. For example, in the crazy altseason of Dec17/Jan18, almost every (low capitalized) altcoin increased its BTC value by a minimum of +300%, some at the beginning of the season, some at the end.
- When this happens, BTC loss capitalization dominance, but this also can happen if BTC is downtrending while altcoins are being bought in BTC markets but its USD value doesn't change too much. This happens when altcoins are uptrending in BTC price, but there are actually no gain of USD value because the BTC gain in value is not enough to compensate the BTC fall in price. Since BTC is losing USD price, but altcoins are not, dominance falls. So, looking at BTC dominance is not enough to spot possible beginnings of altseasons, because of arbitrage of other effects.
- The "big altcoins" are removed from the counting because one single big capitalized altcoin that grows, let's say, a 20%, will have an observable effect on the total altcoin capitalization, even if the rest of the altcoins are stagnated in price. For example, at today's date (8th April 2020), Ethereum by itself has the 23.89% of the total altcoins capitalization. A +10% in Ethereum price will increase the total altcoin capitalization by a +2.38%. I wanted to remove that effect to focus on generalized price changes of all altcoins. Remember that there are only 9 big altcoins 9 coins representing the 71% of the alts capitalization, while there are exists more than 5000 altcoins in total.
- Another key factor is that I want to focus on what happens in alt/BTC markets, because almost every altcoin can be traded against BTC, and most of them can only be traded against BTC. However, big altcoins can usually be traded against USD or other alt coins or fiat currencies as well. Removing the big alts from the equation helps (just a bit) to simplify the interpretation of the chart because arbitrage effects of those "impactfull" alts are limited (although not removed, because arbitrage also happens cross-markets).
- There are situations where BTC price is going up, alts USD capitalization is going up as well, but alts BTC capitalization is going down because altcoins are being sold in BTC markets, it just happens that the speed of the selling is not high enough as to compensated the increased in BTC price. That makes the USD capitalization grows, while alts are really being dumped in BTC markets. I wanted to reflect that effect as well by making sure that the graph is growing only when both USD and BTC capitalization of alts are growing.
Interpretation
============
If you want, you can see this chart as if plotting the Other alts capitalization as if priced against a fictional coin FCOIN, that start by having a price of 1, that combines the up and downs of both BTC price and alts USD capitalization in a very conservative way: if FCOIN price goes up, means that the other alts are gained USD value but only when they have overcome BTC price changes. Otherwise, it goes down.
If this fictional FCOIN has went up during some days straight with a total gain of maybe, greater than 10%, we are maybe in front of the start of an altseason. Sometimes, maybe (it requires some more years to extract a theory out of here), it can be used as proxy of the BTC near future (trend changes or continuations): if this FCOIN goes up, while BTC is doing nothing relevant or even is going down, it could signal that "people" is getting prepared and a generalized altcoin accumulation process has started, because of a combined people's assumption that BTC will start to have an stable uptrend, or will continue the current trend soon. There's some matches in the past about that, but there are also false positives, as usual.
Additionally, four customizable EMAs are added to the script, by default 21, 50, 100 and 150.
Definitions
=========
- Let's call `altcap_btc` the altcoin capitalization in USD, divided by BTC price. In other words, `altcap_btc` is the capitalization in terms of BTC.
- Let's call `x` the BTC price change rate as `btc_price_current_candle / btc_price_previous_candle`. So, if BTC has grown a +20%, `x = 1.20`, and if BTC has gone down a -20%, `x = 0.80`.
- Let's call `y` the `altcap_btc` price change rate, calculated as before but for `altcap_btc`.
- For pure math equivalence, `x * y` is thus the USD capitalization change rate.
Calculation
=========
For plotting the graph, for each candle, I choose a change rate, and then I plot the total accumulated change rate as by `ch0 * ch1 * ch2 * .... * ch_today`, where each `chX` is the choosen change rate of each candle since the beginning of the chart. So, if the "alts compensated value" has grown yesterday +20% and today's -10%, `1.20 * 0.9 = 1.08`, which means that in two days the compensated value has grown an 8% in total.
- If `x * y > 1` (USD cap is growing), I take `y` as change rate (alt/btc change rate).
- If both `x` and `y` are `> 1`, then the graph grows because I'm taking `y`.
- If `x > 1` and `y < 1`, the graph goes down because I'm taking `y`, reflecting the BTC markets are dumping.
- If `x < 1` and `y > 1`, the graph goes up because I'm taking `y`, reflecting the BTC markets are pumping so much that it overcomes the btc fall.
- `x < 1` and `y < 1` is impossible here because `x * y` must be `> 1` by precondition.
- If `x * y < 1` (USD cap is going down), I take `y` or `x * y` depending on the individual change rates:
- If `x` and `y` go in different directions (one up and the other down), I take `x * y` to reflect that USD capitalization has gone down. I don't take `y` here because it could be `> 1`, and I don't want to make the graph grow if alts are lossing USD value. Also, if `y < 1` and I take `y` the graph will go down faster than USD capitalization and I want to show that "alts compensated value is gown down slower than BTC because some boughts are happening". I don't take `x` either here for the same reasons.
- If both `x` and `y` are `< 1`, I take `y`, because otherwise the graph would be less than 0.000001 today after two years of bleeding, making literally impossible to see if alts "grow tomorrow".
- `x > 1` and `y > 1` is impossible here because `x * y` must be `< 1` by precondition.
Spot Symbols for CryptoLibrary "CryptoSpotSymbols"
This Library has one purpose only. It generate Symbols for the Crypto Spot Market, like all the currencies pairs of most Crypto Exchanges available to TradingView.
Have a look at .find() , which is an all in one function.
Binance(basecurrency)
Generate 27 Symbols for the Spot Market of Binance.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BinanceUS(basecurrency)
Generate seven Symbols for the Spot Market of BinanceUS.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitfinex(basecurrency)
Generate 12 Symbols for the Spot Market of Bitfinex.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitFlyer(basecurrency)
Generate three Symbols for the Spot Market of bitFlyer.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitget(basecurrency)
Generate seven Symbols for the Spot Market of Bitget.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bithumb(basecurrency)
Generate two Symbols for the Spot Market of Bithumb.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitkub(basecurrency)
Generate one Symbol for the Spot Market of bitkub.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: THB
BitMEX(basecurrency)
Generate two Symbols for the Spot Market of BitMEX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitpanda_pro(basecurrency)
Generate six Symbols for the Spot Market of bitpanda pro.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
bitrue(basecurrency)
Generate nine Symbols for the Spot Market of bitrue.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Bitstamp(basecurrency)
Generate eight Symbols for the Spot Market of Bitstamp.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BITTREX(basecurrency)
Generate six Symbols for the Spot Market of BITTREX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BTSE(basecurrency)
Generate 15 Symbols for the Spot Market of BTSE.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
BYBIT(basecurrency)
Generate five Symbols for the Spot Market of BYBIT.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CapitalCom(basecurrency)
Generate five Symbols for the Spot Market of capital.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
coinbase(basecurrency)
Generate seven Symbols for the Spot Market of coinbase.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CoinEx(basecurrency)
Generate three Symbols for the Spot Market of CoinEx.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
CurrencyCom(basecurrency)
Generate 30 Symbols for the Spot Market of currency.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Delta(basecurrency)
Generate one Symbol for the Spot Market of Delta.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USDT
Deribit(basecurrency)
Generate two Symbols for the Spot Market of Deribit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
easyMarkets(basecurrency)
Generate one Symbol for the Spot Market of easyMarkets.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
Eightcap(basecurrency)
Generate one Symbol for the Spot Market of Eightcap.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
ExMo(basecurrency)
Generate ten Symbols for the Spot Market of ExMo.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
FOREXcom(basecurrency)
Generate four Symbols for the Spot Market of FOREX.com.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
FXCM(basecurrency)
Generate three Symbols for the Spot Market of FXCM.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
GateIO(basecurrency)
Generate five Symbols for the Spot Market of Gate.io.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Gemini(basecurrency)
Generate ten Symbols for the Spot Market of Gemini.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Kraken(basecurrency)
Generate 14 Symbols for the Spot Market of Kraken.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
KuCoin(basecurrency)
Generate 13 Symbols for the Spot Market of KuCoin.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
MEXC(basecurrency)
Generate six Symbols for the Spot Market of MEXC.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
OANDA(basecurrency)
Generate one Symbol for the Spot Market of OANDA.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
OKX(basecurrency)
Generate six Symbols for the Spot Market of OKX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Pepperstone(basecurrency)
Generate one Symbol for the Spot Market of Pepperstone.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns: USD
phemex(basecurrency)
Generate four Symbols for the Spot Market of phemex.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
POLONIEX(basecurrency)
Generate nine Symbols for the Spot Market of POLONIEX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Pyth(basecurrency)
Generate three Symbols for the Spot Market of Pyth.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
Skilling(basecurrency)
Generate four Symbols for the Spot Market of Skilling.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
TimeX(basecurrency)
Generate six Symbols for the Spot Market of TimeX.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
TradeStation(basecurrency)
Generate four Symbols for the Spot Market of TradeStation.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
UpBit(basecurrency)
Generate four Symbols for the Spot Market of UpBit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
whitebit(basecurrency)
Generate 13 Symbols for the Spot Market of whitebit.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
WOOX(basecurrency)
Generate two Symbols for the Spot Market of WOO.
Parameters:
basecurrency (simple string) : Its the Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`.
Returns:
find(exchange, basecurrency)
Generate up to 30 Symbols for the Spot Market, depending on the market picked.
Parameters:
exchange (simple string) : The name of an Exchange. Case insensitivity. Optional. Default value is `syminfo.prefix`. If something else is put in here it will return `na` values.
basecurrency (simple string) : The Basecurrency to generate the Symbols with. Optional. Default value is `syminfo.basecurrency`
Returns: 30x string as tuple
CL Daily Bitcoin Volume (All exchange included, even Mt.GOX)This daily volume data contains collective total from
____________________________________________________
Historical:
BTC-e BTC/USD (From Q3 2011 to Q3 2016)
BTCChina BTC/CNY (From Q3 2011 to Q2 2017)
Coinsetter BTC/USD (From Q3 2014 to Q1 2016)
MtGox BTC/USD (From July 2010 - 2014 only))
OKcoin International BTC/USD (From Q3 2014 to Q2 2017)
____________________________________________________
Institutions:
CME Bitcoin Futures
Grayscale Bitcoin Trust OTC
____________________________________________________
Spot exchanges:
Bitfinex BTC/USD
Bitstamp BTC/USD
Coinbase BTC/USD
Coinbase BTC/EUR
Binance BTC/USDT
Binance BTC/USDC
Binance BTC/PAX
Gemini BTC/USD
itBit BTC/USD
Kraken BTC/EUR
Kraken BTC/USD
Huobi BTC/USDT
Korbit BTC/KRW
Bitflyer BTC/JPY
____________________________________________________
Others:
Bitmex
Noro's SILA v1.6L StrategyBacktesting
Backtesting (for all the time of existence of couple) only with software configurations to default (without optimization of parameters):
US = Uptrend-Sensivity
DS = Downtrend-Sensivity
It is recommended and by default:
- the normal market requires US=DS (for example US=5, DS=5)
- very bear market requires US DS, (for example US=5, DS=0)
- very bull market requires US DS, (US=0, DS=5)
Cryptocurrencies it is very bull market (US=0, DS=5)
Backtesting BTC/FIAT
D1 timeframe
identical parameters for all pairs
BTC/USD (Bitstamp) profit of +41805%
BTC/EUR (BTC-e) profit of +1147%
BTC/RUB (BTC-e) profit of +1162%
BTC/JPY (Bitflyer) profit of +215%
BTC/CNY (BTCChina) profit of 54948%
Backtesting ALTCOIN/BTC
D1 timeframe
identical parameters for all pairs
the exchange Poloniex
top-10 of cryptocurrencies on capitalization at the time of this text
NA = TradingView can't make backtest because of too low price of this cryptocurrency, or on the website there are no quotations of this cryptocurrency
ETH/BTC (Etherium) profit of +11690%
XRP/BTC (Ripple) loss of-100%
LTC/BTC (Litecoin) NA
ETC/BTC (Etherium Classic) profit of +214%
NEM/BTC loss of-49%
DASH/BTC profit of +106%
IOTA/BTC NA
XMR/BTC (Monero) profit of +96%
STRAT/BTC (Stratis) loss of-31%
ALTCOIN/ALTCOIN - not recomended
I don't need your money, I need reputation and likes.
ZenAlgo - DominatorThis indicator provides a structured multi-ticker overview of market momentum and relative strength by analyzing short-term price behavior across selected assets in comparison with broader crypto dominance and Bitcoin/ETH performance.
Ticker and Market Data Handling
The script accepts up to 9 user-defined symbols (tickers) along with BTCUSD and ETHUSD. For each symbol:
It retrieves the current price.
It also requests the daily opening price from the "D" timeframe to compute intraday percentage change.
For BTC, ETH, and dominance (sum of BTC, USDT, and USDC dominance), daily change is calculated using this same method.
This comparison enables tracking relative performance from the daily open, which provides meaningful insight into intraday strength or weakness among different assets.
Dominance Logic
The indicator aggregates dominance data from BTC , USDT , and USDC using TradingView’s CRYPTOCAP indices. This combined dominance is used as a reference in directional and status calculations. ETH dominance is also analyzed independently.
Changes in dominance are used to infer whether market attention is shifting toward Bitcoin/stablecoins (typically indicating risk-off sentiment) or away from them (typically risk-on behavior, benefiting altcoins).
Price Direction Estimation
The script estimates directional bias using an EMA-based deviation technique:
A short EMA (user-defined lookback , default 4 bars) is calculated.
The current close is compared to the EMA to assess directional bias.
Recent candle changes are also inspected to confirm a consistent short-term trend (e.g., 3 consecutive higher closes for "up").
A small threshold is used to avoid classifying flat movements as trends.
This directionality logic is applied separately to:
The selected ticker's price
BTC price
Combined dominance
This allows the script to contextualize the movement of each asset within broader market conditions.
Market Status Evaluation
A custom function analyzes ETH and BTC dominance trends along with their relative strength to define the overall market regime:
Altseason is identified when BTC dominance is declining, ETH dominance rising, and ETH outperforms BTC.
BTC Season occurs when BTC dominance is rising, ETH dominance falling, and BTC outperforms ETH.
If neither condition is met, the state is Neutral .
This classification is shown alongside each ticker's row in the table and helps traders assess whether market conditions favor Bitcoin, Ethereum, or altcoins in general.
Ticker Status Classification
Each ticker is analyzed independently using the earlier directional logic. Its status is then determined as follows:
Full Bull : Ticker is trending up while dominance is declining or BTC is also rising.
Bullish : Ticker is trending up but not supported by broader bullish context.
Bearish : Ticker is trending down but without broader confirmation.
Full Bear : Ticker is trending down while dominance rises or BTC falls.
Neutral : No strong directional bias or conflicting context.
This classification reflects short-term momentum and macro alignment and is color-coded in the results table.
Table Display and Plotting
A configurable table is shown on the chart, which:
Displays the name and status of each selected ticker.
Optionally includes BTC, ETH, and market state.
Uses color-coding for intuitive interpretation.
Additionally, price changes from the daily open are plotted for each selected ticker, BTC, ETH, and combined dominance. These values are also labeled directly on the chart.
Labeling and UX Enhancements
Labels next to the current candle display price and percent change for each active ticker and for BTC, ETH, and combined dominance.
Labels update each bar, and old labels are deleted to avoid clutter.
Ticker names are dynamically shortened by stripping exchange prefixes.
How to Use This Indicator
This tool helps traders:
Spot early rotations between Bitcoin and altcoins.
Identify intraday momentum leaders or laggards.
Monitor which tickers align with or diverge from broader market trends.
Detect possible sentiment shifts based on dominance trends.
It is best used on lower to mid timeframes (15m–4h) to capture intraday to short-term shifts. Users should cross-reference with longer-term trend tools or structural indicators when making directional decisions.
Interpretation of Values
% Change : Measures intraday move from daily open. Strong positive/negative values may indicate breakouts or reversals.
Status : Describes directional strength relative to market conditions.
Market State : Gives a general bias toward BTC dominance, ETH strength, or altcoin momentum.
Limitations & Considerations
The indicator does not analyze liquidity or volume directly.
All logic is based on short-term movements and may produce false signals in ranging or low-volume environments.
Dominance calculations rely on external CRYPTOCAP indices, which may differ from exchange-specific flows.
Added Value Over Other Free Tools
Unlike basic % change tables or price overlays, this indicator:
Integrates dominance-based macro context into ticker evaluation.
Dynamically classifies market regimes (BTC season / Altseason).
Uses multi-factor logic to determine ticker bias, avoiding single-metric interpretation.
Displays consolidated information in a table and chart overlays for rapid assessment.






















