OPEN-SOURCE SCRIPT

EnsembleX

77
📌 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.

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。