Back to Coding

Advanced HYBRID Scalper EA

Prompt

Create a complete MQL5 Expert Advisor (.mq5) script implementing an advanced forex HYBRID scalping strategy that supports both automatic and manual (M0) entries management with adaptive features. This EA must adhere to the following detailed requirements: - Utilize multi-timeframe analysis on M1, M5, and M15 charts. - Incorporate the core technical indicators: EMA with periods 8, 21, 50; RSI with period 14; MACD with parameters (12,26,9); Bollinger Bands (period 20, deviation 2). - Use secondary indicators: Stochastic oscillator and Average True Range (ATR). - Dynamically detect and score support and resistance (S/R) lines based on touch count, reaction strength, recency, and volume. - Identify key candlestick reversal patterns near significant S/R lines, including Doji, Hammer, Shooting Star, Engulfing, Pin Bars, and Inside Bars. - Establish an entry confluence system requiring at least 4 out of these 6 conditions: * EMA21 bias on M5 timeframe indicating trend direction. * RSI values surpassing defined thresholds for overbought/oversold. * MACD histogram direction confirming momentum. * Valid candlestick pattern near S/R with volume confirmation. * Pullback towards EMA or a significant S/R level. - Limit trade frequency by market session: * Maximum 4 active trades during London/New York sessions. * Maximum 2 active trades during Asian session. * Fixed lot size of 0.02 per entry. - Tune Asian session trade entries to prioritize safety, entering fewer but high-probability trades. - Implement a multi-layer exit strategy: * Strict “No RED” rule—avoid closing trades at a loss unless triggered by exit rules. * Apply a 250-point dynamic group hedge to manage price reversals. * Support group closing where trades (original entry plus hedges) share the first entry’s ticket number. * Use adaptive stop loss starting from ATR-based distance, moving to break-even plus 40 pips after reaching the first profit target (accounting for spreads and fees). * Deploy a dynamic step sniper trailing stop moving 80 pips behind price. * Trailing stops based on EMA8. * Begin closing trades 30 minutes prior to major news events. - Enforce risk management: * Position sizing based on 1% account risk dynamically adjusted by ATR and signal strength. * Daily loss limits enforced. * Avoid trading during major news periods (placeholder for news API integration). - Write modular, well-structured, and readable code with comprehensive inline comments explaining all logic, especially adaptive and risk management parts. - Provide comprehensive configurable input parameters covering all key settings. - Use only standard MQL5 indicators and trading functions. - Implement robust error handling and graceful fallback for unexpected market conditions. - Include placeholders for external APIs (news events, volume sources). - Log all closed trades (single or grouped) in the journal tab with total profit/loss including fees and charges, ensuring no spam. # Steps 1. Initialize and manage technical indicators for M1, M5, and M15 timeframes. 2. Detect, score, and maintain dynamic support/resistance lines. 3. Compute indicators and identify candlestick patterns on M1. 4. Calculate signal confluence and initiate trade entries when at least 4 conditions are met. 5. Calculate precise position sizing according to risk and ATR adjustments. 6. Manage active trades for manual and automatic entries including group closures, hedges, adaptive stops, trailing stops, and session filters. 7. Integrate session time and news filters to control trade entries. # Output Format Deliver the entire Expert Advisor source code as a complete `.mq5` file content string featuring: - A detailed header comment block summarizing EA purpose, configuration inputs, and high-level strategy description. - Clearly defined and commented input parameters for all configurable variables. - Modular code structure with well-separated functions handling indicator calculations, pattern recognition, trade entry logic, trade management, and risk control. - Extensive inline comments explaining core logic, particularly around adaptive features, risk management, and exit strategies. - Placeholder comments for integrating external data sources such as: * News API for major event detection. * Volume data sources. - Pay strict attention to maintainability, performance efficiency, and safeguard against invalid data. - Ensure compilability and readiness for deployment. # Notes - Focus on safety and reliable operation under live market conditions. - Use standardized MQL5 coding best practices. - Maintain concise, descriptive variable and function names. - Strictly follow the provided scalping strategy, no deviations. Generate the full, ready-to-compile MQL5 Expert Advisor source code implementing this complex adaptive forex scalping strategy now.

Related Coding Prompts

Write Code

As a seasoned programmer, your task is to write code in [programming language] to [perform action]. The code should be efficient, well-structured, and optimized for performance. Make sure to follow best practices and industry standards while implementing the necessary algorithms and logic to achieve the desired functionality. Test the code thoroughly to ensure it functions as intended and meets all requirements. Additionally, document the code properly for future reference and maintenance.

Debug Code

Act as a seasoned programmer with over 20 years of commercial experience. Analyze the provided [piece of code] that is causing a specific [error]. Your task involves diagnosing the root cause of the error, understanding the context and functionality intended by the code, and proposing a solution to fix the issue. Your analysis should include a step-by-step walkthrough of the code, identification of any bugs or logical mistakes, and a detailed explanation of how to resolve them. Additionally, suggest any improvements or optimizations to enhance the performance, readability, or maintainability of the code based on your extensive experience. Ensure that your solution adheres to best practices in software development and is compatible with the current development environment where the code is being executed.

Do Code Review

As a seasoned programmer with over 20 years of commercial experience, your task is to perform a comprehensive code review on the provided [piece of code]. Your review should meticulously evaluate the code's efficiency, readability, and maintainability. You are expected to identify any potential bugs, security vulnerabilities, or performance issues and suggest specific improvements or optimizations. Additionally, assess the code's adherence to industry standards and best practices. Your feedback should be constructive and detailed, offering clear explanations and recommendations for changes. Where applicable, provide examples or references to support your suggestions. Your goal is to ensure that the code not only functions as intended but also meets high standards of quality and can be easily managed and scaled in the future. This review is an opportunity to mentor and guide less experienced developers, so your insights should be both educational and actionable.