Overview
This prompt aims to guide developers in creating an MQL5 Expert Advisor for automated forex trading. Programmers and traders seeking to implement advanced scalping strategies will benefit from this detailed framework.
Prompt Overview
Purpose: This EA automates forex trading using a scalping strategy for enhanced trading efficiency.
Audience: It is designed for traders seeking to leverage automated systems for forex market analysis and execution.
Distinctive Feature: The EA incorporates multi-timeframe analysis and dynamic support/resistance for informed trading decisions.
Outcome: Users can expect improved trade accuracy and risk management through systematic entry and exit strategies.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Development Tools & DevOps, General Business Operations
- Techniques: Plan-Then-Solve, Role/Persona Prompting, 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 simple MQL5 Expert Advisor (EA) for automated forex trading based on the advanced forex scalping bot strategy framework described below.
The EA should implement the core strategy architecture featuring:
– Multi-timeframe analysis: M1, M5, M15.
– Key indicators:
– EMA (8, 21, 50)
– RSI (14)
– MACD (12, 26, 9)
– Bollinger Bands (20, 2)
– Secondary indicators: Stochastic and ATR.
– Dynamic support/resistance lines: Identified via an automated line marking system as specified.
**Entry Rules**:
– Implement entry rules for long and short trades using the confluence scoring method (minimum 4 out of 6 conditions), including:
– Bias from EMA21 on M5.
– RSI levels.
– MACD histogram direction.
– Candlestick pattern recognition at significant S/R levels with volume confirmation.
– Pullbacks to EMA or support/resistance.
**Exit Strategy**:
– Include an exit strategy with:
– Partial profit targets based on ATR multiples and support/resistance levels.
– Adaptive stop loss (initial ATR-based, break-even after target 1 hit, trailing with EMA 8).
– Time-based exits (max 30 min duration, close before major news).
**Risk Management Rules**:
– Apply risk management rules for position sizing based on:
– 1% account risk adjusted by ATR volatility and signal strength multiplier.
– Daily loss limits.
– Consecutive loss tracking with position size reduction.
**Market Session Optimizations**:
– Trade mainly during London and New York sessions.
– Avoid trading around major news.
– Reduce size during low-volatility periods.
The EA should include the following main components:
1. Multi-timeframe analysis: Gathering data from M1, M5, M15 charts.
2. Automated detection and scoring: Dynamic support/resistance lines based on touch count, reaction strength, recency, and volume criteria.
3. Indicator calculations: EMA, RSI, MACD, Bollinger Bands, Stochastic, ATR.
4. Candlestick pattern recognition: For Doji, Hammer, Shooting Star, Engulfing, Pin Bars, and Inside Bars at key levels.
5. Entry signal generation: Using the confluence scoring system, including volume evaluation.
6. Position sizing calculation: Per strategy.
7. Trade management: With partial profit taking, adaptive stops, and time-based exits.
8. Session-based trade filtering: And news event avoidance.
**Code Guidelines**:
– Keep the code clear and modular for ease of future enhancements.
– Include comments explaining key blocks referencing the provided strategy framework.
# Steps
– Initialize indicators on required timeframes and prepare necessary buffers.
– Implement functions to detect and score support/resistance levels from recent price data.
– Write routines for multi-indicator analysis and candlestick pattern detection on M1 bars.
– Develop confluence scoring logic for entries and enforce minimum threshold.
– Compute position size dynamically using ATR volatility and account risk.
– Manage open trades with multiple partial profit targets and trailing stop logic.
– Integrate session and news filtering logic to pause trading accordingly.
# Output Format
Provide the full MQL5 EA source code as a single `.mq5` file content with:
– Proper formatting.
– Indentation.
– Comprehensive in-line comments reflecting the strategy details.
# Notes
– The implementation should prioritize correctness and clarity over exhaustive optimization.
– Assume access to standard MQL5 functions for indicator calculation and trading operations.
– All parameters like ATR periods, risk percentages, etc., should be configurable inputs.
– Include safeguards against trading during unexpected market conditions or invalid data.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Paste the prompt into your preferred coding environment.
- Modify any parameters as needed for your trading strategy.
- Run the code to generate the MQL5 Expert Advisor.
- Test the EA in a demo account before live trading.
- Adjust settings based on performance and market conditions.
Tips for Best Results
- Multi-timeframe Setup: Initialize M1, M5, and M15 indicators for comprehensive analysis.
- Confluence Scoring: Ensure at least 4 out of 6 conditions are met for trade entries using a scoring system.
- Dynamic Risk Management: Adjust position sizes based on ATR volatility and maintain strict daily loss limits.
- Session Optimization: Focus trading during London and New York sessions while avoiding major news events.
FAQ
- What is the purpose of the MQL5 Expert Advisor?
The EA automates forex trading based on an advanced scalping strategy using multiple indicators. - Which timeframes does the EA analyze?
The EA analyzes M1, M5, and M15 timeframes for trading signals. - What indicators are used in the EA?
The EA uses EMA, RSI, MACD, Bollinger Bands, Stochastic, and ATR for decision-making. - How does the EA manage risk?
Risk management includes position sizing based on account risk, daily loss limits, and tracking consecutive 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.


