OPEN-SOURCE SCRIPT
EnsembleX

📌 EnsembleX – Multi-Feature Voting Strategy
//version=5
//fenyesk
🔹 Overview
EnsembleX is a multi-indicator ensemble trading Strategy that combines price action, momentum, volume, and volatility signals into a unified consensus model. Instead of relying on a single indicator, EnsembleX uses a weighted voting system to determine trade entries and exits, making it more adaptive across different market conditions (crypto, forex, and equities).
The system calculates feature-engineered signals, normalizes them, applies lagged context, and then uses ensemble consensus weighting to decide whether to go long or short. An adaptive threshold (ATR-based) ensures risk-sensitive entries during volatile or quiet regimes.
🔹 Core Features
📈 Trend & Momentum Features
EMA Slope (f_slope): Captures directional bias and steepness of trend.
RSI (f_rsi): Measures overbought/oversold conditions with normalization.
CCI (f_cci): Detects price deviations from mean for extreme reversals.
ADX (f_adx, DMI+/-): Evaluates trend strength and directional dominance.
📊 Volatility Features
Standard Deviation (f_stdev): Captures volatility spikes relative to history.
Bollinger Band Position (f_bb): Measures where price sits within BB envelope.
Log Returns (f_logr): Tracks distribution-adjusted price changes.
💵 Volume-Based Features
MFI (f_mfi): Volume-weighted momentum confirming price moves.
Volume Pressure (f_vol): Combines normalized volume ratio with price change.
🧮 Feature Engineering
Normalization & Z-score scaling: Keeps features comparable across regimes.
Lag Features (optional): Adds short-term historical context to signals.
Composite Aggregates:
Momentum Composite (mom): RSI + CCI + MFI blend.
Trend Composite (trd): ADX + Slope blend.
Volatility Composite (volat): StDev + Volume blend.
🔹 Signal Generation
Each feature produces an expert signal (+1 bull, -1 bear, 0 neutral). Examples:
RSI rising from oversold → Bull signal.
ADX strong + DMI+ dominance → Bull signal.
Bollinger Band breakout + reversal → Bear signal.
Volume pressure > threshold → Directional confirmation.
🔹 Ensemble Voting Mechanism
Each signal is assigned a weight (weight_rsi, weight_adx, weight_mfi, etc.).
Final bull/bear confidence is computed as a weighted probability.
Trades trigger only when consensus ≥ threshold.
Threshold adapts dynamically based on ATR / volatility regime.
🔹 Trading Logic
✅ Long Entry:
Bull consensus ≥ threshold and stronger than bear side.
✅ Short Entry:
Bear consensus ≥ threshold and stronger than bull side.
✅ Optional Exits:
Close on opposite signal flip (configurable by position side).
🔹 Visualization
Plots bull and bear confidence curves.
Plots both base threshold and adaptive ATR-adjusted threshold.
Easy to see how consensus builds before trades trigger.
⚡ Key Benefits
Robustness: Reduces reliance on any single indicator.
Flexibility: Works across assets and timeframes (crypto, forex, stocks).
Adaptive: Threshold adjusts automatically in volatile or quiet markets.
Transparency: Plotted consensus and threshold lines make signals easy to interpret.
📢 Usage Notes
Best used on 1h–4h for swing trades, or 5m–15m for intraday setups.
Combine with risk management (TP/SL, position sizing) for live trading.
Ensemble weights (weight_rsi, weight_adx, etc.) can be tuned per asset.
👉 This script is designed for backtesting and research. Results vary depending on the asset, timeframe, and parameter tuning.
//version=5
//fenyesk
🔹 Overview
EnsembleX is a multi-indicator ensemble trading Strategy that combines price action, momentum, volume, and volatility signals into a unified consensus model. Instead of relying on a single indicator, EnsembleX uses a weighted voting system to determine trade entries and exits, making it more adaptive across different market conditions (crypto, forex, and equities).
The system calculates feature-engineered signals, normalizes them, applies lagged context, and then uses ensemble consensus weighting to decide whether to go long or short. An adaptive threshold (ATR-based) ensures risk-sensitive entries during volatile or quiet regimes.
🔹 Core Features
📈 Trend & Momentum Features
EMA Slope (f_slope): Captures directional bias and steepness of trend.
RSI (f_rsi): Measures overbought/oversold conditions with normalization.
CCI (f_cci): Detects price deviations from mean for extreme reversals.
ADX (f_adx, DMI+/-): Evaluates trend strength and directional dominance.
📊 Volatility Features
Standard Deviation (f_stdev): Captures volatility spikes relative to history.
Bollinger Band Position (f_bb): Measures where price sits within BB envelope.
Log Returns (f_logr): Tracks distribution-adjusted price changes.
💵 Volume-Based Features
MFI (f_mfi): Volume-weighted momentum confirming price moves.
Volume Pressure (f_vol): Combines normalized volume ratio with price change.
🧮 Feature Engineering
Normalization & Z-score scaling: Keeps features comparable across regimes.
Lag Features (optional): Adds short-term historical context to signals.
Composite Aggregates:
Momentum Composite (mom): RSI + CCI + MFI blend.
Trend Composite (trd): ADX + Slope blend.
Volatility Composite (volat): StDev + Volume blend.
🔹 Signal Generation
Each feature produces an expert signal (+1 bull, -1 bear, 0 neutral). Examples:
RSI rising from oversold → Bull signal.
ADX strong + DMI+ dominance → Bull signal.
Bollinger Band breakout + reversal → Bear signal.
Volume pressure > threshold → Directional confirmation.
🔹 Ensemble Voting Mechanism
Each signal is assigned a weight (weight_rsi, weight_adx, weight_mfi, etc.).
Final bull/bear confidence is computed as a weighted probability.
Trades trigger only when consensus ≥ threshold.
Threshold adapts dynamically based on ATR / volatility regime.
🔹 Trading Logic
✅ Long Entry:
Bull consensus ≥ threshold and stronger than bear side.
✅ Short Entry:
Bear consensus ≥ threshold and stronger than bull side.
✅ Optional Exits:
Close on opposite signal flip (configurable by position side).
🔹 Visualization
Plots bull and bear confidence curves.
Plots both base threshold and adaptive ATR-adjusted threshold.
Easy to see how consensus builds before trades trigger.
⚡ Key Benefits
Robustness: Reduces reliance on any single indicator.
Flexibility: Works across assets and timeframes (crypto, forex, stocks).
Adaptive: Threshold adjusts automatically in volatile or quiet markets.
Transparency: Plotted consensus and threshold lines make signals easy to interpret.
📢 Usage Notes
Best used on 1h–4h for swing trades, or 5m–15m for intraday setups.
Combine with risk management (TP/SL, position sizing) for live trading.
Ensemble weights (weight_rsi, weight_adx, etc.) can be tuned per asset.
👉 This script is designed for backtesting and research. Results vary depending on the asset, timeframe, and parameter tuning.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.