Overview
This prompt aims to guide developers in creating a MetaTrader 5 Expert Advisor for a specific trading strategy. Coders and traders will benefit from the structured approach and detailed requirements for implementing the strategy effectively.
Prompt Overview
Purpose: This Expert Advisor automates the 15-Minute Opening Range Breakout trading strategy in MetaTrader 5.
Audience: It is designed for traders familiar with MQL5 and looking to enhance their trading efficiency.
Distinctive Feature: The EA identifies breakout opportunities from the first 15-minute candle and manages trades effectively.
Outcome: Users can expect improved trading performance through automated execution and risk management.
Quick Specs
- Media: Text
- Use case: Content Creation, Generation, Planning & Strategy
- Industry: Consulting (Management, Strategy), Cryptocurrency & Blockchain, Fintech & Digital Banking
- Techniques: 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 an Expert Advisor (EA) in MetaTrader 5 (MT5) that implements the 15-Minute Opening Range Breakout (ORB) trading strategy as described below.
**Strategy Details:**
– Range Candle:
– Identify the first 15-minute candle of the trading session (e.g., 10:00–10:15 or 15:00–15:15).
– Entry:
– Monitor subsequent 5-minute candles.
– When a 5-minute candle closes outside the established range high or low of the 15-minute range candle,
– Place a limit order at the breakout price (the boundary where the candle closes outside the range),
– This is considered the ORB line.
– Stop Loss:
– Set the stop loss at the middle price of the 15-minute range candle.
– For buy trades, the stop loss is below the middle;
– For sell trades, the stop loss is above the middle.
– Take Profit:
– Set take profit at double the range height (i.e., 2 times the difference between the high and low of the range candle), measured from the entry price.
**Requirements:**
– The EA should:
– Accurately identify the 15-minute opening range candle based on the session times specified.
– Monitor 5-minute candles for breakout signals.
– Upon breakout, place limit orders at the breakout level (ORB line).
– Manage trades with the specified stop loss and take profit.
– Implement proper risk management and error handling.
– Enable backtesting to evaluate strategy performance within MT5’s strategy tester.
**Steps:**
1. Define the time range and detect the first 15-minute candle of the session.
2. Calculate the high, low, and middle price of that candle.
3. Monitor 5-minute candles for closes outside the range.
4. On breakout, place the appropriate limit order at the breakout price.
5. Set stop loss and take profit according to the strategy.
6. Manage open positions and exit criteria.
**Output Format:**
– Provide the complete MQL5 source code for the EA, ready to compile and backtest in the MT5 editor.
– Include comments within the code explaining key sections and logic for clarity.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your preferred code editor for MQL5.
- Paste the prompt into the editor.
- Follow the steps outlined in the prompt to code the EA.
- Compile the code in the MT5 editor.
- Backtest the EA using MT5’s strategy tester.
Tips for Best Results
- Identify Opening Range: Detect the first 15-minute candle of the trading session to establish the high, low, and middle price.
- Monitor Breakouts: Track 5-minute candles for closures beyond the established range to trigger limit orders at breakout levels.
- Set Risk Parameters: Implement stop loss below the middle for buys and above for sells, while setting take profit at double the range height.
- Backtest Strategy: Ensure the EA allows for backtesting in MT5 to evaluate performance and refine the strategy based on historical data.
FAQ
- What is the 15-Minute Opening Range Breakout strategy?
It's a trading strategy that uses the first 15-minute candle to identify breakout opportunities. - How do you identify the range candle?
The range candle is the first 15-minute candle of the trading session. - What triggers a trade entry in this strategy?
A trade entry occurs when a 5-minute candle closes outside the established range high or low. - How is the stop loss calculated?
The stop loss is set at the middle price of the 15-minute range candle.
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.


