Overview
This prompt aims to guide developers in creating a MetaTrader 5 expert advisor using the 9 EMA indicator. Programmers and traders will benefit by gaining a structured approach to automate trading strategies effectively.
Prompt Overview
Purpose: The goal is to create an automated trading bot using the 9 EMA for effective market analysis and trading.
Audience: This EA is designed for traders and developers familiar with MetaTrader 5 and MQL5 programming language.
Distinctive Feature: The bot uniquely leverages the 9 EMA crossover strategy to identify optimal buy and sell signals.
Outcome: Users will receive a fully functional EA that executes trades based on the 9 EMA with integrated risk management features.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Development Tools & DevOps, General Business Operations
- Techniques: Plan-Then-Solve, Self-Consistency, 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 a detailed and effective MetaTrader 5 (MT5) expert advisor (EA) AI bot that utilizes the 9-period Exponential Moving Average (9 EMA) as its core trading indicator.
The bot should be designed to:
– Analyze market data
– Identify trading signals based on the 9 EMA crossover or related strategies
– Execute buy or sell orders automatically
**Requirements:**
– Implement the 9 EMA indicator calculation on price data.
– Develop trading logic that triggers entries and exits based on the 9 EMA pattern or crossovers.
– Incorporate risk management features such as:
– Stop-loss
– Take-profit
– Position sizing
– Optimize the bot’s decision-making process for various market conditions.
– Provide clear and structured MQL5 code compatible with the MT5 platform.
**Steps:**
1. Explain the concept and calculation of the 9 EMA.
2. Outline the trading strategy using the 9 EMA, for example:
– Buy when price crosses above the 9 EMA
– Sell when it crosses below
3. Develop the EA structure, including:
– Initialization
– Deinitialization
– OnTick function
4. Code the 9 EMA indicator logic.
5. Implement signal detection and trading order execution.
6. Add risk management parameters.
7. Include comments and documentation within the code for clarity.
**Output Format:**
Provide the complete MQL5 source code for the MT5 expert advisor implementing the 9 EMA trading strategy. Ensure to include comprehensive comments explaining each part of the code and a summary of how the bot operates.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Paste it into your preferred coding environment.
- Follow the outlined steps to create the EA.
- Implement the MQL5 code as specified.
- Test the EA on the MT5 platform.
- Refine the code based on performance results.
Tips for Best Results
- Understand 9 EMA: The 9-period Exponential Moving Average (EMA) gives more weight to recent prices, making it responsive to new information.
- Trading Signals: Buy when the price crosses above the 9 EMA and sell when it crosses below; this indicates potential trend reversals.
- Risk Management: Implement stop-loss and take-profit levels based on market volatility to protect your capital and secure profits.
- Optimize Performance: Test and adjust the EA’s parameters in different market conditions to enhance its decision-making and profitability.
FAQ
- What is the 9-period Exponential Moving Average (EMA)?
The 9 EMA is a technical indicator that gives more weight to recent prices, smoothing price data. - How does the 9 EMA trading strategy work?
Buy when the price crosses above the 9 EMA and sell when it crosses below. - What are key components of the EA structure?
Key components include initialization, deinitialization, and the OnTick function for trading logic. - What risk management features should be included?
Incorporate stop-loss, take-profit, and position sizing to manage trades effectively.
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.


