Overview
This prompt aims to create a comprehensive MQL4 Expert Advisor for advanced trading strategies in MetaTrader 4. Programmers and traders will benefit by obtaining a robust, automated trading tool tailored for various market conditions.
Prompt Overview
Purpose: This Expert Advisor automates advanced trading strategies for efficient market engagement in MetaTrader 4.
Audience: Designed for experienced traders seeking to leverage sophisticated algorithms for enhanced trading performance.
Distinctive Feature: Integrates Fibonacci retracements, fractal signals, and dynamic risk management for a comprehensive trading approach.
Outcome: Users can expect improved trade execution, optimized risk management, and adaptability to market conditions.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Banking (Retail & Commercial), Development Tools & DevOps, Productivity & Workflow
- Techniques: Function Calling / Tool Use, 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
Generate a fully integrated Expert Advisor (EA) coded in MQL4 for MetaTrader 4 that incorporates the following advanced trading techniques and features:
– Fibonacci Retracements:
– Based on previous daily highs and lows.
– Automatic daily updates and accurate calculations.
– Fractal-Based Entry Signals:
– Strict validation of fractal wick lengths before triggering entries.
– Real-Time Volatility Filtering:
– Using Average True Range (ATR), Bollinger Bands, and spread analysis.
– Optimize trade timing and frequency.
– Hedging Logic:
– Maintain market neutrality by opening offsetting positions to neutralize market exposure.
– High-Frequency Scalping Strategies:
– Inspired by institutional methods, including:
– Mean reversion.
– Order flow scalping.
– Fibonacci and fractal signals.
– Arbitrage opportunities.
– Dynamic Trade Frequency Adjustment:
– Based on current market volatility:
– Increase trades during stable, low-volatility periods.
– Reduce during high volatility.
– Dynamic Trailing Stops:
– Adapt in response to evolving market conditions to protect profits and reduce losses.
– Adaptive Risk Management:
– Ensure maximum loss of $0.50 per lot per trade.
– Dynamically calculate and adjust stop-loss levels.
– Real-Time Trade Execution:
– Execute all trades without delays, suitable for live account environments.
# Implementation Details:
– Calculate Fibonacci retracement levels at the start of each new day using the previous day’s high and low prices.
– Detect fractal formations on relevant timeframes and validate each fractal’s wick length meets minimum criteria before entry.
– Continuously monitor volatility metrics (ATR, Bollinger Bands width, spread) and only allow trades within optimal volatility ranges.
– Implement hedging by opening counter positions automatically when triggered, ensuring overall market exposure is neutralized.
– Incorporate scalping and high-frequency trading (HFT) methods encompassing:
– Mean reversion strategies.
– Order flow analysis.
– Fibonacci & fractal signals.
– Arbitrage opportunities.
– Adjust trailing stops based on market volatility and price movement patterns dynamically.
– Ensure per-trade risk stays within $0.50 per lot by dynamically adjusting stop-loss distance based on current volatility and market conditions.
– Handle edge cases such as sudden volatility spikes, market gaps, and spread widening gracefully.
– Use efficient, clean, and well-commented MQL4 code adhering to best practices for order handling, memory management, and live trading performance.
– Provide configurability for standard major currency pairs with the ability to adapt to others.
# Steps:
1. On each new trading day, compute and store Fibonacci retracement levels from the previous day’s high and low.
2. Analyze incoming bars to identify fractal patterns and validate fractal wick lengths strictly.
3. Continuously calculate ATR, Bollinger Bands width, and spread to evaluate market volatility.
4. Modulate trade frequency dynamically based on volatility metrics.
5. Execute hedging trades to maintain market neutrality when conditions evolve.
6. Apply trailing stops that update dynamically with market moves.
7. Calculate appropriate stop-loss distances dynamically to maintain maximum risk of $0.50 per lot.
8. Place, modify, and close trades without delay.
# Output Format:
Produce a fully functioning, compiled MQL4 Expert Advisor (.mq4 source code) file. The source code must be:
– Fully commented, explaining:
– Calculation logic.
– Trade signal generation.
– Hedging mechanism.
– Risk management.
– Structured for readability and maintainability.
– Tested and optimized for live trading conditions.
# Notes:
– Prioritize execution speed and resource efficiency to ensure live trading responsiveness.
– Carefully handle abnormal market events (gaps, spread widening, sudden volatility) with safeguards within the code.
– Follow MQL4 best practices for trade handling, error checking, and memory management.
Generate the complete, integrated MQL4 Expert Advisor source code to satisfy all the above requirements.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your preferred code editor for MQL4.
- Paste the prompt into the editor.
- Modify any specific parameters as needed.
- Compile the code to check for errors.
- Test the EA in a demo account before live trading.
Tips for Best Results
- Fibonacci Retracements: Automatically calculate daily Fibonacci levels using previous day’s high and low for precise entry points.
- Fractal Validation: Ensure fractal wick lengths meet strict criteria before executing trades to enhance entry accuracy.
- Volatility Filtering: Use ATR and Bollinger Bands to optimize trade timing, increasing trades during low volatility and reducing in high volatility.
- Dynamic Risk Management: Adjust stop-loss levels dynamically to maintain a maximum loss of $0.50 per lot per trade, ensuring robust risk control.
FAQ
- What are Fibonacci retracements in trading?
Fibonacci retracements are horizontal lines indicating potential support and resistance levels based on Fibonacci ratios. - How do fractals signal entry points?
Fractals identify price patterns that suggest potential reversals, validated by specific wick length criteria. - What is the purpose of real-time volatility filtering?
It optimizes trade timing and frequency by analyzing market volatility using ATR and Bollinger Bands. - How does dynamic trade frequency adjustment work?
It increases trades during low volatility and reduces them during high volatility to manage risk 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.


