Overview
This prompt aims to guide developers in creating a robust Expert Advisor for automated trading. Coders and traders will benefit from the structured approach to building a reliable trading tool.
Prompt Overview
Purpose: The Expert Advisor automates trading to operate continuously, maximizing market opportunities without human intervention.
Audience: This EA is designed for traders using MetaTrader 4 or 5 who seek automated, efficient trading solutions.
Distinctive Feature: It includes robust risk management features and customizable trading strategies for tailored user experiences.
Outcome: Users can expect a reliable, error-resistant trading tool that functions 24/7 with minimal downtime.
Quick Specs
- Media: Text
- Use case: Content Creation, Enhancement, Generation
- Industry: Consulting (Management, Strategy), Fintech & Digital Banking, Productivity & Workflow
- Techniques: Role/Persona Prompting, Self-Critique / Reflection, Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
Create an Expert Advisor (EA) for automated trading that operates continuously 24/7 without interruption.
The EA must meet the following requirements:
– Monitor the market and execute trades at any time of day or night.
– Include robust risk management features such as:
– Configurable stop loss
– Take profit
– Dynamic position sizing
– Be designed specifically for the indicated trading platform:
– MetaTrader 4 (MQL4)
– MetaTrader 5 (MQL5)
– Implement a clear, well-defined trading strategy (e.g., trend following or mean reversion) with customizable parameters for the user.
– Handle runtime errors gracefully to ensure stable, continuous operation without manual intervention or downtime.
# Steps
1. Clearly define the target trading platform and programming language:
– MQL4 for MetaTrader 4
– MQL5 for MetaTrader 5
2. Specify or create the trading strategy logic, including:
– Entry conditions
– Exit conditions
3. Implement continuous market data monitoring and order handling within the EA code.
4. Integrate comprehensive risk management features, including:
– Adjustable stop loss
– Take profit levels
– Position sizing based on account equity or risk percentage
5. Incorporate error handling and recovery mechanisms to avoid interruptions.
6. Test and debug the EA to ensure reliable 24/7 operation.
# Output Format
Provide the complete, well-commented source code of the Expert Advisor in the appropriate syntax for the chosen platform (MQL4 or MQL5).
# Notes
– Ensure all important functions and logic sections are clearly commented to enhance code clarity.
– Mention any dependencies or special settings required to run the EA.
– Emphasize mechanisms included in the code to maintain stable continuous operation and error resilience.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Identify the target trading platform: MQL4 or MQL5.
- Define your trading strategy with entry and exit conditions.
- Implement risk management features like stop loss and take profit.
- Add error handling to ensure continuous operation.
- Test the EA thoroughly for reliability and performance.
Tips for Best Results
- Choose Your Platform: Decide between MQL4 for MetaTrader 4 or MQL5 for MetaTrader 5 based on your trading needs.
- Define Your Strategy: Clearly outline entry and exit conditions for your trading strategy to ensure effective execution.
- Implement Risk Management: Include features like adjustable stop loss, take profit, and dynamic position sizing to protect your capital.
- Error Handling: Integrate robust error handling mechanisms to maintain uninterrupted operation and ensure the EA can recover from runtime issues.
FAQ
- What is an Expert Advisor (EA) in trading?
An EA is an automated trading system that executes trades based on predefined strategies. - Which platforms support MQL4 and MQL5?
MQL4 is for MetaTrader 4, while MQL5 is for MetaTrader 5, both popular trading platforms. - What is dynamic position sizing?
Dynamic position sizing adjusts trade sizes based on account equity or predefined risk percentage. - How does error handling improve EA performance?
Error handling ensures the EA can recover from issues, maintaining continuous operation without manual intervention.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


