Advanced MQL4 EA Generator
Prompt
You are to generate a fully integrated, high-performance Expert Advisor (EA) coded in MQL4 for MetaTrader 4 that implements all the advanced trading techniques and features outlined below. This EA must: - Compute Fibonacci retracement levels daily using the previous day's high and low. - Detect fractals and validate fractal wick lengths strictly before trade entries. - Monitor volatility in real-time using ATR, Bollinger Bands width, and spread analysis to optimize trade timing and frequency. - Implement hedging logic to maintain market neutrality by opening offsetting positions, neutralizing exposure automatically. - Include institutional-style high-frequency scalping strategies such as mean reversion, order flow scalping, Fibonacci and fractal signals, and arbitrage opportunities. - Dynamically adjust trade frequency based on current market volatility—more trades during stable, low volatility periods, fewer during high volatility. - Use adaptive trailing stops that respond dynamically to evolving market conditions to protect profits and limit losses. - Employ adaptive risk management ensuring losses do not exceed $0.50 per lot per trade by dynamically adjusting stop-loss levels, using pending orders, trailing stops, and immediate break-even when appropriate. - Use BuyStop/SellStop orders configured for ultra-fast market execution and automatic, intelligent order management. - Guarantee stop-loss protection and intelligent trailing stop functionality for each position. - Execute all trades in real-time without delays, suitable for live trading environments. Implementation specifics include: - Calculating Fibonacci retracements at each new trading day start based on prior day high and low. - Strict fractal detection using wick length validation. - Continuous volatility evaluation with ATR, Bollinger Bands width, and spread. - Automatic hedging to maintain market neutrality. - Integration of scalping and HFT strategies with mean reversion, order flow analysis, Fibonacci/fractal signals, and arbitrage. - Dynamic trailing stop adjustments based on volatility and price movement. - Risk per trade capped at $0.50 per lot through dynamic stop-loss sizing. - Robust handling of volatility spikes, market gaps, and spread widening. - Efficient, clean, well-commented code adhering to MQL4 best practices for live trading performance. - Configurability primarily for major currency pairs with flexibility to adapt to others. # Steps 1. At each new trading day, compute and store Fibonacci retracement levels from the previous day's high and low. 2. Continuously analyze incoming bars to detect fractal patterns, strictly validating wick lengths. 3. Calculate ATR, Bollinger Bands width, and spread continuously to assess volatility. 4. Dynamically modulate trade frequency depending on volatility metrics. 5. Implement hedging trades automatically to maintain market exposure neutrality. 6. Apply trailing stops that update dynamically with market moves. 7. Calculate and adjust stop-loss distances dynamically to ensure maximum risk per trade is $0.50 per lot. 8. Place, modify, and close trades instantly without delay. # Output Format - Provide a fully functioning MQL4 Expert Advisor source code file (.mq4). - Ensure the source code is thoroughly commented, explaining calculation logic, trade signal generation, hedging, risk management, and execution flow. - Structure code cleanly and modularly for readability and maintainability. - Optimize and test code for robust performance in live trading conditions. # Notes - Prioritize efficient execution and resource management for instantaneous trade responsiveness. - Implement safeguards for abnormal market conditions including gaps, sudden volatility spikes, and spread widening. - Follow MQL4 best practices for order handling, memory management, and error checking. Your response should be the complete MQL4 source code text implementing this Expert Advisor exactly following the above specifications, fully commented and production-ready for immediate live use.
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.