Ema bb rsi
- Experts
- Versione: 1.1
EMA + RSI + Bollinger Bands Trend EA (MetaTrader 5)
This Expert Advisor (EA) is a fully automated, multi-timeframe trading system designed for MetaTrader 5. It trades by aligning with the long-term trend and entering the market during short-term, extreme pullbacks. By combining moving averages for trend direction with momentum oscillators for precision entries, it aims to capture high-probability reversals within an established trend.
📈 Core Trading Strategy
The EA utilizes a strict multi-tier confirmation process before taking any trade:
Buy Entry Rules (Bullish Setup):
- Higher Timeframe (HTF) Trend: Price must be above the 200 EMA on the HTF (e.g., H1).
- Execution Timeframe Trend: Price must also be above the 200 EMA on the current trading chart.
- Exhaustion / Oversold: The RSI (14) must drop below the oversold threshold (default: 15).
- Volatility Piercing: The candle's Low must touch or pierce the Lower Bollinger Band, signaling a temporary overextension.
Sell Entry Rules (Bearish Setup):
- Higher Timeframe (HTF) Trend: Price must be below the 200 EMA on the HTF.
- Execution Timeframe Trend: Price must also be below the 200 EMA on the current trading chart.
- Exhaustion / Overbought: The RSI (14) must rise above the overbought threshold (default: 85).
- Volatility Piercing: The candle's High must touch or pierce the Upper Bollinger Band.
⚙️ Key Features
- Multi-Timeframe Trend Filter: Prevents the EA from taking trades against the dominant HTF market direction, significantly reducing false signals.
- On-Chart Dashboard: A sleek, real-time visual panel that displays:
- Current HTF and Execution TF trend states (Bullish/Bearish).
- Status of Buy/Sell engines.
- The last generated signal.
- Current Lot sizing, open positions, and floating Profit/Loss.
- Active TP, SL, and Trailing parameters.
- Dynamic Risk Management: Features an "Auto Lot" mode that calculates trade size as a percentage of the total account balance, automatically scaling risk as the account grows. A "Manual Lot" fallback is also available.
- Profit-Lock Trailing Stop: An advanced trade management system that waits for a trade to reach a specific profit threshold (Profit Lock) before it activates. Once triggered, it trails the price by a fixed step distance, securing gains while giving the trade room to breathe.
- Concurrency Control: A built-in toggle ( OnlyOneTradeAtATime ) ensures the EA does not overexpose the account by stacking multiple positions simultaneously.
🛡️ MQL5 Market-Ready & Robustness
The code is specifically engineered to pass strict MQL5 Validator stress tests:
- Pre-Trade Margin Verification: It simulates the required margin via OrderCalcMargin() before executing any order, safely aborting if the account lacks sufficient free margin (preventing fatal "No money" server errors).
- Anti-Spam Trailing Logic: The trailing stop requires a minimum distance threshold before updating, preventing the EA from spamming the broker's server with micro-modifications every tick (Error 10016).
- Zero-Divide Protection: Safely calculates lot step sizes across varying broker environments.
