Tarea técnica

# H4 Zone Retest EA (MQL5)

An automated trading Expert Advisor (EA) for MetaTrader 5, developed in MQL5.  
The EA trades gold (XAUUSD) using a multi-timeframe breakout and retest strategy: it defines the first H4 candle of each day as a trading zone, detects breakouts on the M5 chart, waits for a retest, and executes trades with risk management, trailing stops, and optional news filtering.

---

## Features

- H4 → M5 breakout and retest trading logic  
- Configurable fixed lot or risk-based position sizing  
- Trailing stop management  
- **Smart news filter** that avoids trading around high-impact events  
- Spread and terminal safety checks  
- Dynamic lot calculation based on risk percentage  

## Strategy Overview

1. **Zone identification (H4)**  
   The EA marks the first H4 candle of the current day and stores its high and low as the trading zone boundaries.

2. **Breakout detection (M5)**  
   On each new M5 candle:  
   - A bullish breakout occurs when the candle closes above `zoneHigh`.  
   - A bearish breakout occurs when the candle closes below `zoneLow`.  
   When a breakout occurs, the EA starts waiting for a retest.

3. **Retest entry**  
   - If price returns to the broken zone within a specified window (`MaxWaitSeconds`):  
     - **Buy** on bullish retest → SL = breakout candle low, TP = 1.5 × risk distance.  
     - **Sell** on bearish retest → SL = breakout candle high, TP = 1.5 × risk distance.  
   - Uses either a fixed lot (`Lots`) or a risk-based lot (`UseRiskPercent`, `RiskPercent`).

4. **Trade management and protection**  
   - Trailing stop control (`UseTrailingStop`, `TrailingStart`, `TrailingStep`).  
   - Spread and trade-permission checks (`MaxSpreadPoints`, `TERMINAL_TRADE_ALLOWED`).  
   - **Built-in news filter**: the EA checks the MetaTrader 5 economic calendar (`CalendarValueHistory`) and automatically avoids opening new trades within the defined window around **high-impact news events** for a selected currency (`NewsFilterCurrency`, `NewsFilterMinutes`).  
   - This filter helps prevent entries during volatile periods and improves stability during major market announcements.


## Input Parameters

| Parameter | Description | Default |
|------------|-------------|----------|
| `Lots` | Fixed lot size per trade | 0.01 |
| `UseRiskPercent` | Enable dynamic lot sizing by risk | false |
| `RiskPercent` | Percent of balance risked per trade | 1.0 |
| `MaxWaitSeconds` | Maximum time allowed for retest | 86400 |
| `UseTrailingStop` | Enable trailing stop | true |
| `TrailingStart` | Profit (points) before trailing begins | 200 |
| `TrailingStep` | Distance (points) of trailing stop | 100 |
| `UseNewsFilter` | Enable high-impact news filter | true |
| `NewsFilterMinutes` | Minutes before/after news to avoid trading | 30 |
| `MagicNumber` | Unique identifier for EA positions | 202503 |

---

## Requirements

- MetaTrader 5 platform  
- Broker supporting XAUUSD (gold) trading  
- MQL5 environment (MetaEditor)  
- Historical data for backtesting  

---

## Installation

1. Open **MetaEditor** → *File → Open Data Folder*  
2. Copy the `.mq5` file into `MQL5/Experts/`  
3. Compile the EA  
4. In MetaTrader 5, open *Navigator → Expert Advisors*  
5. Attach the EA to a **XAUUSD** chart  
6. Adjust input parameters as needed  

---
## Backtest
**Symbol:** XAUUSD  
**Timeframe:** M5  
**Period:** Jan 2024 – Apr 2026  
**Model:** Every tick (MetaTrader 5 Strategy Tester)





### Notes
- Default parameters were used unless otherwise stated.  
- The test includes realistic spreads and commissions.  
- Results are for research and educational purposes only and do not guarantee future performance.




Archivos adjuntos:

Han respondido

1
Desarrollador 1
Evaluación
(392)
Proyectos
506
23%
Arbitraje
60
57% / 25%
Caducado
59
12%
Libre
2
Desarrollador 2
Evaluación
(434)
Proyectos
640
53%
Arbitraje
34
62% / 21%
Caducado
6
1%
Trabaja
3
Desarrollador 3
Evaluación
Proyectos
1
0%
Arbitraje
0
Caducado
1
100%
Libre
4
Desarrollador 4
Evaluación
(109)
Proyectos
180
25%
Arbitraje
24
17% / 75%
Caducado
16
9%
Libre
5
Desarrollador 5
Evaluación
(3)
Proyectos
4
25%
Arbitraje
0
Caducado
0
Trabajando
Ha publicado: 1 ejemplo
6
Desarrollador 6
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
7
Desarrollador 7
Evaluación
(1)
Proyectos
1
100%
Arbitraje
0
Caducado
0
Libre
8
Desarrollador 8
Evaluación
(45)
Proyectos
52
58%
Arbitraje
2
100% / 0%
Caducado
1
2%
Libre
Ha publicado: 5 ejemplos
9
Desarrollador 9
Evaluación
(6)
Proyectos
8
38%
Arbitraje
1
100% / 0%
Caducado
2
25%
Libre
10
Desarrollador 10
Evaluación
(3)
Proyectos
4
0%
Arbitraje
0
Caducado
0
Libre
11
Desarrollador 11
Evaluación
(14)
Proyectos
18
22%
Arbitraje
1
100% / 0%
Caducado
4
22%
Trabajando
12
Desarrollador 12
Evaluación
(4)
Proyectos
4
25%
Arbitraje
0
Caducado
0
Libre
13
Desarrollador 13
Evaluación
(25)
Proyectos
32
19%
Arbitraje
5
40% / 40%
Caducado
4
13%
Trabaja
14
Desarrollador 14
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
15
Desarrollador 15
Evaluación
(9)
Proyectos
10
10%
Arbitraje
0
Caducado
0
Libre
16
Desarrollador 16
Evaluación
(8)
Proyectos
8
0%
Arbitraje
2
50% / 0%
Caducado
1
13%
Trabaja
17
Desarrollador 17
Evaluación
(298)
Proyectos
478
40%
Arbitraje
105
40% / 24%
Caducado
82
17%
Trabajando
Ha publicado: 2 ejemplos
18
Desarrollador 18
Evaluación
(14)
Proyectos
20
25%
Arbitraje
0
Caducado
2
10%
Libre
Ha publicado: 3 ejemplos
19
Desarrollador 19
Evaluación
(10)
Proyectos
14
43%
Arbitraje
0
Caducado
3
21%
Libre
20
Desarrollador 20
Evaluación
(258)
Proyectos
302
76%
Arbitraje
13
77% / 0%
Caducado
4
1%
Trabajando
21
Desarrollador 21
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
22
Desarrollador 22
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
23
Desarrollador 23
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
24
Desarrollador 24
Evaluación
(1)
Proyectos
0
0%
Arbitraje
1
0% / 100%
Caducado
0
Libre
25
Desarrollador 25
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
26
Desarrollador 26
Evaluación
(49)
Proyectos
74
18%
Arbitraje
30
17% / 53%
Caducado
31
42%
Libre
27
Desarrollador 27
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
28
Desarrollador 28
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
29
Desarrollador 29
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
30
Desarrollador 30
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
31
Desarrollador 31
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
32
Desarrollador 32
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
33
Desarrollador 33
Evaluación
Proyectos
1
0%
Arbitraje
0
Caducado
0
Libre
Ha publicado: 2 ejemplos
34
Desarrollador 34
Evaluación
(1)
Proyectos
1
0%
Arbitraje
0
Caducado
0
Libre
Ha publicado: 1 ejemplo
35
Desarrollador 35
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
36
Desarrollador 36
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
Solicitudes similares
I am looking to see if you can convert my pinescript into a NinjaTrader bot so I can get automated trading instead of manually doing it in TradingView i would like to get it to just do the trades for me based on my script. let me know who can do this perfectly
8 cap prop firm passing 30 - 3000 USD
I am looking for an experienced MQL4/MQL5 HFT developer to build or optimize a High-Frequency Trading (HFT) Expert Advisor that can successfully pass proprietary trading firm challenges and perform consistently under live trading conditions with brokers such as 8cap or BlackBull Markets . The developer should have proven experience with HFT execution, ultra-low-latency trading, broker execution, slippage, spreads
I have a High-Frequency Trading (HFT) Expert Advisor for both MT4 and MT5 designed primarily for US30 (Dow Jones Index) . The EA performs consistently and profitably on demo accounts, but when I run it on an IC Markets Raw or Standard live account, it starts generating losses under what appear to be the same trading conditions. At this time, I cannot provide the source code (.mq4/.mq5). I can only provide the
Version document : 1.0 Plateforme : TradingView Langage : Pine Script v6 Type : Indicateur d'analyse et d'aide à la décision (non-exécutant) 1. Présentation du projet Nom du produit ONYX SR V2 — Intelligent Support & Resistance Scalping System Objectif Créer un indicateur TradingView capable d'identifier automatiquement des opportunités de scalping basées sur : supports et résistances dynamiques ; action du prix ;

Información sobre el proyecto

Presupuesto
30+ USD
Plazo límite de ejecución
a 10 día(s)