Advanced Multi-Timeframe Forex Robot
Prompt
You are to develop a professional and advanced Forex trading robot (Expert Advisor) for the MetaTrader 5 (MT5) platform that implements a multi-timeframe, swing trading, trend-following strategy based on the detailed specifications below. Strategy Details: 1. Timeframes & Indicators: - Daily (High Time Frame - HTF): * RSI: Period 25; Buy Level = 54; Sell Level = 46 * ATR: Period 14 - 1 Hour (Semi-HTF): * RSI: Period 25; Buy Level = 54; Sell Level = 46 * ATR: Period 14 - 15 Minutes (Low Time Frame - LTF): * RSI: Period 3; Buy Level = 26; Sell Level = 74 * ATR: Period 14 2. Entry Criteria: - Buy Entries: * HTF: Enter first buy when RSI 25 crosses above 54 from below 46, indicating trend start. * Semi-HTF: After HTF buy confirmation, enter second buy when Semi-HTF RSI crosses above 54 from below. * LTF: With Semi-HTF RSI above 54, enter buys on every RSI 3 crossing above 26 at candle close. - Sell Entries: * HTF: Enter first sell when RSI 25 crosses below 46 from above 54. * Semi-HTF: After HTF sell confirmation, enter second sell when Semi-HTF RSI crosses below 46 from above. * LTF: With Semi-HTF RSI below 46, enter sells on every RSI 3 crossing below 74 at candle close. 3. Exit Criteria: - Close all buy trades if HTF RSI crosses below 46. - Close all sell trades if HTF RSI crosses above 54. 4. Trade Management: - Lot size: Default 0.5% of account balance; allow manual lot size input defaulting to 1 lot. - Stop Loss: 2 x ATR (appropriate to trade’s timeframe). - Take Profit: 6 x ATR for HTF and Semi-HTF trades; 4 x ATR for LTF trades. - Breakeven: Optional activation at 2.5 x ATR + 0.5 x ATR buffer. - Daily Drawdown Limit: 4% of account balance (stop trading further during that day if exceeded). 5. Customization: - Allow all indicator parameters (periods, levels) and trade management settings (lot size, SL, TP, breakeven, drawdown limit) to be fully customizable via inputs. 6. Additional Features: - Assign unique magic number and trade comment to all trades. - Implement a professional-grade dashboard displaying: * Trend direction and signal status on all timeframes (Daily, 1H, 15m). * Account metrics including current profit/loss, drawdown, and equity information. 7. Performance & Reliability: - Optimize code to prevent memory leaks and array overflows. - Ensure efficient data handling to avoid lag. - Implement robust error handling and logging. Your solution should: - Follow best coding practices and include appropriate comments. - Use consistent naming conventions. - Ensure the EA is user-friendly with clear input options and intuitive interface. # Output Format Provide the full source code of the MT5 Expert Advisor in MQL5 language. Include detailed comments for every main section and important logic. Provide explanations or notes about how customization parameters map to the strategy. # Notes - Strictly implement candle close RSI crosses for entering trades on LTF. - Ensure trades are entered only if the higher timeframe RSI conditions remain valid. - Consider ATR values of the respective timeframe when calculating SL and TP. - The dashboard should update live and be visually clear without clutter. Create this Expert Advisor code accordingly.
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.