metatrader-5

byArun Varma

Act as an expert MQL5 developer and algorithmic trading engineer. Create a complete MetaTrader 5 (MT5) Expert Advisor (EA) with the following specifications: 1. Strategy Logic Timeframe: H1 (1-hour chart) Entry signals: Identify swing highs and swing lows (configurable lookback, e.g., 5 bars on each side). Enter on a retest of the swing high/low level after a breakout or rejection. Opposite-direction closing: When a valid opposite signal appears, close existing positions in the opposite direction. Retest entry: Enter only after price retests the broken swing level, confirmed by a rejection candle (e.g., pin bar or engulfing pattern). Maximum 10 positions per level: Limit open trades to 10 per swing level. Track each level independently. 2. Position Sizing & Risk Management Fixed lot mode: User-defined fixed lot size. Auto lot mode: Calculate lot size based on a configurable risk percentage of account equity (e.g., 1% of equity), using stop-loss distance and symbol tick value/contract size. Account size compatibility: Automatically adapt to any account size (cent, mini, standard) by reading account balance, equity, minimum/maximum/step lot from symbol properties, and normalizing lots accordingly. Stop loss & take profit: Configurable in points or ATR-based multiples. Max drawdown / daily loss protection: Optional halt when a set equity drawdown or daily loss % is reached. 3. Flapping-Style Behavior Support the 'flapping' (scale-in/layered) style: multiple small positions added at successive retest levels, each with its own TP/SL, managed as a group with optional group-level break-even or trailing. 4. Dashboard On-chart panel showing: current equity, balance, % risk setting, open positions count per level, total floating P/L, last signal, daily P/L, and EA status (running/paused). Buttons or inputs to pause/resume trading and to close all positions. 5. Technical Requirements Written in MQL5 with clean, commented code and organized input parameters (grouped by Strategy, Risk, Dashboard). Use CTrade class for order execution with slippage and magic number settings. Include error handling and logging via Print() for order failures, lot normalization, and signal events. Backtest-friendly: no repainting logic; signals based only on closed bars. 6. Deliverables Complete .mq5 source code, ready to compile. Brief explanation of each input parameter. Recommended settings for a 1% risk, H1 test on EURUSD. Notes on limitations and suggested backtesting steps.

No preview

Comments (0)

No comments yet. Be the first!

System Requirements

System Requirement Document
📝

Requirements Not Generated Yet

The SRD will be automatically generated as you discuss your project with the Tech Lead Agent.

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

No user flows yet.

The User Flow Agent will generate per-persona navigation diagrams after SRD updates.

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

No user flows yet.

The User Flow Agent will generate per-persona navigation diagrams after SRD updates.