Overview
This prompt aims to guide developers in creating an effective trading bot for Gold using MQL4. Programmers and traders will benefit from the structured approach to building a high-performance trading system.
Prompt Overview
Purpose: The trading bot aims to capitalize on short-term price movements in Gold (XAUUSD) using advanced trading strategies.
Audience: This bot is designed for traders seeking automated solutions to enhance their trading performance in volatile markets.
Distinctive Feature: It incorporates technical indicators and dynamic risk management techniques to optimize entry and exit points effectively.
Outcome: The bot is expected to achieve a high win rate and significant profits through rigorous backtesting and real-time adjustments.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Fintech & Digital Banking, Productivity & Workflow
- Techniques: Plan-Then-Solve, 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
Design a trading bot in MQL4 that aggressively trades Gold (XAUUSD) while maintaining a high win rate by capitalizing on short-term price movements using scalping and breakout strategies.
The bot should:
– Incorporate technical indicators such as:
– Moving Averages
– RSI
– MACD
to generate precise entry and exit signals.
– Implement advanced risk management techniques to:
– Minimize losses
– Maximize profit potential amid volatility.
– Adapt dynamically to varying market conditions through:
– Position sizing
– Trade adjustments based on current market volatility.
Follow these detailed steps:
1. Market Analysis:
– Identify and code detection of key support and resistance levels for XAUUSD.
2. Define Entry/Exit Rules:
– Specify clear, indicator-based criteria for:
– Opening positions
– Closing positions using scalping and breakout signals.
3. Position Sizing:
– Program dynamic lot sizing based on:
– Account equity
– Predefined risk tolerance parameters.
4. Backtesting:
– Use historical price data to rigorously test the bot’s performance, iteratively refining logic to improve the win rate.
5. Monitoring and Alerts:
– Implement real-time monitoring and alerts to:
– Track trade performance
– Allow for strategy adjustments when necessary.
Ensure compliance with MetaTrader platform standards, factoring in spread and slippage effects inherent in aggressive trading environments.
# Output Format
– Provide the full MQL4 bot code with detailed comments explaining each function and logic block.
– Include a comprehensive summary of the trading strategy, detailing backtest performance metrics such as:
– Number of trades executed
– Win rate percentage
– Net profit
– Duration covered by the historical data.
# Example Structure
“`mql4
int OnInit() {
/* Initialize indicators and variables */
return(INIT_SUCCEEDED);
}
void OnTick() {
/* Execute trading logic based on indicator signals and market conditions */
}
double CalculateRisk() {
/* Compute risk per trade dynamically */
return riskValue;
}
“`
Summary example:
“The bot executed 100 trades with a win rate of 70%, achieving an overall profit of $X over 3 months of backtested data.”
# Important Notes
– Ensure adaptability to various market volatility scenarios through dynamic trade management.
– Account for real trading nuances such as spread and slippage when calculating profitability.
– Maintain code clarity and modularity to facilitate easy adjustment for diverse trading environments.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Paste it into your preferred coding environment.
- Follow the outlined steps to design the trading bot.
- Implement the specified technical indicators and strategies.
- Test and refine the bot using historical data.
- Review the output format for performance metrics.
Tips for Best Results
- Market Analysis: Code detection of key support and resistance levels for XAUUSD to inform trading decisions.
- Entry/Exit Rules: Establish clear, indicator-based criteria for opening and closing positions using scalping and breakout signals.
- Position Sizing: Implement dynamic lot sizing based on account equity and predefined risk tolerance to manage exposure effectively.
- Backtesting: Rigorously test the bot’s performance with historical data to refine logic and improve win rate metrics.
FAQ
- What indicators should the trading bot use?
The bot should use Moving Averages, RSI, and MACD for entry and exit signals. - How can the bot minimize losses?
Implement advanced risk management techniques and dynamic position sizing based on market conditions. - What is the purpose of backtesting?
Backtesting evaluates the bot's performance using historical data to refine trading logic. - What should be monitored in real-time?
Track trade performance and adjust strategies as needed based on market volatility.
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.


