Overview
This prompt aims to guide developers in creating a MetaTrader EA for a specific scalping strategy. Programmers and traders will benefit by gaining a structured approach to automate their trading strategies effectively.
Prompt Overview
Purpose: This EA script aims to automate a 5-minute scalping strategy using Exponential Moving Averages for efficient trading.
Audience: It is designed for traders and developers familiar with MetaTrader and MQL4/MQL5 programming languages.
Distinctive Feature: The EA autonomously manages trade entries, exits, and risk management based on EMA signals, ensuring swift execution.
Outcome: Users will receive a fully functional, well-commented script ready for compilation and testing in MetaTrader.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Data & Analysis, General Business Operations
- Techniques: Self-Critique / Reflection, Structured Output, Zero-Shot Prompting
- 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) script for MetaTrader that implements a 5-minute scalping strategy based on the Exponential Moving Average (EMA).
**Requirements and Details:**
– Timeframe: 5-minute charts.
– Indicators: Use one or more EMA indicators to determine entry and exit points.
– Scalping Conditions:
– Enter a trade when price crosses EMA.
– Enter a trade when a shorter EMA crosses a longer EMA.
– Risk Management: Include appropriate stop loss and take profit levels suitable for scalping.
– Autonomy: The EA should manage trade entries, exits, and risk management autonomously.
– Programming Language: Use MQL4 or MQL5.
– Code Comments: Provide clear comments in the code explaining each part of the logic.
**Steps to Accomplish the Task:**
1. Initialize indicators and parameters for EMA periods.
2. On each new tick or bar, check for EMA-based trading signals.
3. If entry conditions are met and no open position exists, open a buy or sell order.
4. Set stop loss and take profit according to scalping best practices.
5. Monitor open trades and close if exit conditions are met or profit/loss limits are reached.
**Output Format:**
Provide the complete MQL4 or MQL5 script code implementing the EA, fully commented, ready to be compiled and tested in the MetaTrader platform.
**Example (conceptual):**
“`
// Initialization of EMA periods
// Check for EMA crossover
// Open buy/sell position
// Set stop loss and take profit
// Manage open trades
“`
**Notes:**
– The scalping strategy should be simple, focusing on fast in-and-out trades.
– Avoid complex or multi-timeframe signals to keep the EA lightweight.
– Ensure proper money management and risk controls are in place.
**Code Quality:** Ensure the code is clean, efficient, and well-documented for ease of understanding and modification.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your preferred code editor for MQL4 or MQL5.
- Paste the prompt into the editor as a reference.
- Follow the outlined steps to write the EA script.
- Ensure to comment on each part of the code.
- Compile and test the script in MetaTrader.
Tips for Best Results
- Initialize EMAs: Set up the EMA periods and indicators in the script to prepare for trading signals.
- Check Signals: On each tick, evaluate if the price crosses the EMA or if a shorter EMA crosses a longer EMA to determine entry points.
- Manage Trades: Open buy/sell orders based on conditions, and implement stop loss and take profit levels to protect capital.
- Monitor Positions: Continuously check open trades to close them when exit conditions are met or if profit/loss thresholds are reached.
FAQ
- What is the purpose of an Expert Advisor in MetaTrader?
An Expert Advisor automates trading strategies, managing entries, exits, and risk management without manual intervention. - How does the EMA crossover signal trades?
A trade is triggered when the price crosses the EMA or when a shorter EMA crosses a longer EMA. - What is the recommended timeframe for this scalping strategy?
The strategy is designed for 5-minute charts to capitalize on short-term price movements. - Why is risk management important in scalping?
Risk management protects capital by setting stop loss and take profit levels, minimizing potential losses.
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.


