Overview:TheRange Breakout EAis a powerful automated trading system designed to capitalize on breakout opportunities during the early hours of market activity. By leveraging a well-defined strategy, this EA identifies the first-hour range of price movement and places pending orders to capture subsequent breakout momentum. Additionally, it features an optional Martingale mechanism for enhanced recovery and profit maximization after a loss.
Key Features:
1. First Hour Range Breakout Strategy
- Identifies the high and low of the first hour of the trading day.
- Draws a visual rectangle on the chart to highlight the first-hour range for easy reference.
- Places Buy Stop and Sell Stop orders at the breakout levels to capture price momentum.
2. Configurable Parameters
- LotSize:Adjustable lot size to match your risk management profile.
- TP_Multiplier & SL_Multiplier:Customizable multipliers for setting Take Profit and Stop Loss levels relative to the first-hour range.
- CancelHours:Automatically cancels pending orders after a specified number of hours if not triggered.
- MaxDailyAttempts:Limits the number of trading attempts per day to prevent over-trading.
- RangeColor:Selectable color for visually marking the first-hour range on the chart.
3. Advanced Order Management
- Ensures pending orders adhere to broker-defined stop-level requirements.
- Automatically deletes old pending orders that exceed the specified active time frame.
- Logs detailed messages for every action taken, including order placement, adjustments, and deletions.
4. Optional Martingale Recovery
- Enables a recovery mechanism for Stop Loss trades by placing a new pending order with the same lot size but on the opposite breakout side.
- Provides the flexibility to toggle Martingale logic on or off.
- Prevents over-exposure by capping the maximum lot size allowed by the broker.
5. Risk Management
- Caps the first-hour range to prevent orders based on unrealistically large ranges.
- Respects broker-imposed volume and price movement limits.
- Designed to minimize drawdowns and manage trading risks efficiently.
6. Fully Automated Execution
- Runs seamlessly without requiring user intervention.
- Automatically resets daily parameters to ensure accurate calculations and strategy execution.
How It Works:
-
Initialization:
- The EA starts by detecting the beginning of a new trading day and resets all parameters.
- It waits for the first hour of the day to complete before calculating the range.
-
Range Calculation:
- Captures the high and low prices of the first hour (from 00:00 to 01:00 server time).
- Visually marks the range on the chart for user clarity.
-
Order Placement:
- Places Buy Stop and Sell Stop orders at the breakout levels beyond the first-hour range.
- Sets Take Profit and Stop Loss levels based on user-defined multipliers.
-
Order Monitoring:
- Continuously monitors active trades and pending orders.
- Cancels untriggered orders after the specified CancelHours duration.
-
Martingale Recovery (Optional):
- If a Stop Loss is triggered, the EA places a recovery order on the opposite breakout side to recover losses.
-
End of Day Reset:
- At the end of the day, the EA resets all parameters and prepares for the next trading session.
Note on Martingale Mechanism:
The Martingale recovery mechanism in the Range Breakout EA is strictly limited to the same trading day and is only activated if the first order of the day fails (i.e., hits the Stop Loss).
- The EA will place a recovery order on the opposite breakout side of the first trade, using the same lot size as the initial trade.
- If the recovery order is triggered, no further Martingale trades will be placed for that day, even if the recovery trade also hits Stop Loss.
- The Martingale mechanism resets daily, ensuring that the risk is contained within a single trading session and does not escalate across multiple days.
This approach ensures disciplined risk management while allowing for potential recovery after an initial loss.
User Inputs:
| Parameter | Description |
| LotSize | Lot size for all orders. |
| CancelHours | Hours after which pending orders are canceled if untriggered. |
| TP_Multiplier | Multiplier for Take Profit levels based on the first-hour range. |
| SL_Multiplier | Multiplier for Stop Loss levels based on the first-hour range. |
| RangeColor | Color used to highlight the first-hour range on the chart. |
| MaxDailyAttempts | Maximum number of trading attempts per day. |
| EnableMartingale | Toggles the Martingale recovery mechanism on or off. |
Ideal for Traders Who:
- Prefer structured breakout strategies with visual clarity.
- Want a fully automated solution to manage trades without manual intervention.
- Need a recovery mechanism to mitigate losses.
- Require flexibility in risk and reward settings for various trading styles.
Compatibility:
- Supported Platforms: MetaTrader 5.
- Instruments: Suitable for Forex, commodities, indices, and other high-liquidity instruments.
- Timeframes: Designed specifically for the daily timeframe, utilizing M1 data for range calculations.