Adaptive EA Refactor
Prompt
You are an MQL5 expert tasked with evolving a base Expert Advisor (EA) script into a robust, adaptive trading system that dynamically senses market conditions and fine-tunes its strategy accordingly. Begin by incorporating the original EA script as your foundation to ensure all enhancements build on a verified codebase. Carefully analyze the provided input data snippet to understand parameters and data inputs currently used. Extract detailed stage-by-stage steps required for fine-tuning this strategy, organizing your approach to map the evolution of the EA clearly. List all relevant testing parameters in a well-structured table format to serve as a checklist for systematic testing and validation. Simulate various parameter combinations under specific market conditions, acting as an experienced day trader. Use historical market data from January 2025 onward, recent price action, key technical indicators (especially RSI and MACD), and current relevant news to guide your analysis. Identify optimal entry points, stop-loss levels, and targets for the specified trading asset. Develop fine-tuning stages including testing breakout versus mean-reversion strategies in different market regimes. Present an updated EA script broken into clear, tagged stages to reflect each phase of strategy evolution. Add a drop-down input toggle in the EA to allow easy switching between these tuning stages during backtesting. Merge your updated signal logic, risk management engine, and trade execution routines into the original EA codebase. Integrate a market auto-sensing module enhanced with an RSI and MACD-based sentiment filter that enables the EA to: - Detect bullish or bearish momentum, - Dynamically adjust scoring and trading decisions depending on trend vs. reversal regimes, - Execute trades only when signal confirmation, momentum, and volatility align, - Enforce a 2-minute cooldown period between trades, - Prevent opening new positions while an existing position is active. Incorporate intuitive, adaptive trading logic enabling the EA to trade beyond standard rules through context-aware decision making. Finally, consolidate all amendments into a single, well-structured, minimalistic MQL5 EA script using shortened code where possible but maintaining readability. The script should be provided in plain text split into manageable parts, fully commented with stage tags and input toggles, ready to deploy. Ensure the EA dynamically senses and adapts to market conditions in real time using RSI and MACD inputs to drive trade decisions. # Steps 1. Attach and validate the original base EA script as foundation. 2. Analyze provided input snippet to understand parameters. 3. Extract and organize fine-tuning plan in logical stages. 4. Create a parameter testing table listing variables and ranges. 5. Simulate diverse parameter sets with focus on recent market data and technical indicators (RSI, MACD). 6. Define stage-wise strategies comparing breakout and mean reversion. 7. Generate updated EA script with clear stage tags. 8. Add user input dropdown menu to toggle between stages. 9. Integrate refined signal logic, risk and execution modules into base EA. 10. Embed enhanced auto-sensing module using RSI and MACD to detect momentum and adapt strategy. 11. Implement a 2-minute cooldown between trades and prevent overlapping positions. 12. Incorporate adaptive, intuitive trading logic for context-aware decisions. 13. Consolidate all updates into a single, commented MQL5 script in plaintext, supplied in parts here. # Output Format - Provide the updated, complete MQL5 EA script in plain text, split into logically separated parts for readability. - Include comprehensive comments with stage tags and input toggle descriptions. - Supply a neatly formatted table of testing parameters as markdown. - Summarize the fine-tuning stages with bullet points. # Notes - Maintain minimalistic, efficient MQL5 code without unnecessary complexity. - Ensure dynamic adaptation to market regimes using RSI and MACD for momentum detection. - Enforce trade cooldown and position management to avoid conflicts. - Base all simulations and strategy choices on real historical data from January 2025 to current date. - The solution is intended to be ready for immediate copy-paste deployment. # Response Formats ## prompt {"prompt":"[Full detailed prompt as above without JSON metadata]","name":"Adaptive EA Refactor","short_description":"Enhances an MQL5 EA to dynamically adapt to market conditions using RSI and MACD, with stage-wise tuning and backtest toggles.","icon":"CodeBracketIcon","category":"programming","tags":["MQL5","Trading","EA","Strategy","Automation"],"should_index":true}
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.