Guarda come scaricare robot di trading gratuitamente
Ci trovi su Telegram!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Sistemi Esperti

H4 Breakout Retest EA for Gold (XAUUSD) - sistema esperto per MetaTrader 5

Visualizzazioni:
16
Pubblicato:
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

H4BreakoutRetest_XAU trades gold with a simple breakout and retest pattern. The first 4 hours of the broker day (server time) define a zone made of the high and the low of that period. When an M5 candle closes outside the zone, the EA waits for the price to come back and test the broken level (the retest). When an M5 candle closes again outside the zone, it enters in the direction of the breakout. Stop loss and take profit are fixed percentages of the entry price (default 2% and 4%, risk to reward 1:2). The lot size is calculated from the risk percentage and the stop distance.

Balance curves of the backtests


DISCLAIMER: this Expert Advisor is provided for educational and research purposes only and is not financial advice. Trading CFDs on gold is high risk and you can lose more than your deposit. Backtest results are hypothetical, do not include every real world cost (slippage, requotes, changing spreads and swaps) and do not guarantee future results. Test it on a demo account first and never risk money you cannot afford to lose. The author accepts no responsibility for any loss.


How it works:

- Zone: high and low of the first ZoneHours hours of the server day (default 00:00-04:00)

- Breakout: an M5 candle closes above the zone high (long) or below the zone low (short)

- Retest: the price comes back to touch the broken level

- Entry: an M5 candle closes again outside the zone in the direction of the breakout, market order

- Exit: fixed stop loss and take profit, no trailing

- Protections: maximum spread, maximum number of entries per day, minimum lot risk check, free margin check, drawdown guard that pauses the EA when equity falls MaxDrawdownPercent below its peak


Inputs:

- ZoneStartHour, ZoneHours: position and length of the zone (server time)

- StopLossPercent, TakeProfitPercent: stop and target as % of the entry price

- RiskPercent: risk per trade as % of equity

- MaxMinLotRiskPct: skip the trade if the broker minimum lot would risk more than this % of equity

- MaxSpreadPoints, MaxTradesPerDay, MaxDrawdownPercent, DrawdownCooldownDays, MagicNumber, DeviationPoints

- AllowStacking: see below


AllowStacking (important):

With AllowStacking = false (default) the EA keeps one position at a time. With AllowStacking = true a new signal can add to an open position. On a netting account the volumes are merged and the stop and target are replaced by those of the newest trade, so the EA behaves like a pyramiding trend follower: it gives much higher results in strong trends and also much deeper drawdowns. Two presets are attached (default and stacking).


Backtest summary (strategy tester, GOLD M5, 10,000 EUR, risk 1%, 1 minute OHLC model, ActivTrades data; the every tick model gave the same results within 2%):

Period 2019-2022: AllowStacking=false PF 0.93, -4.4%, max drawdown 20.7% | AllowStacking=true PF 0.61, -40.1%, max drawdown 49.6%

Period 2023 to Sep 2026: AllowStacking=false PF 1.19, +12.5%, max drawdown 14.7% | AllowStacking=true PF 1.39, +47.4%, max drawdown 34.9%

Period 2025 to Sep 2026: AllowStacking=false PF 1.50, +18.1%, max drawdown 7.4% | AllowStacking=true PF 2.17, +63.6%, max drawdown 13.6%


IMPORTANT NOTES ON THE RESULTS:

- The results depend strongly on the gold trend. Gold rose strongly in 2024-2026, and in 2019-2022 the EA lost money in both modes.

- Changing the stop loss (1.5-2.5%) and take profit (3-6%) around the defaults did not give stable results in 2019-2022: there is no proven edge outside the rally. Use the EA as a learning tool and not as a ready made system.

- The zone uses the broker server time. Set ZoneStartHour for your broker if its day does not start at 00:00 as the first H4 candle.

- It was tested on a netting account. Hedging accounts handle several positions separately and give different results.

- Works on gold (XAUUSD / GOLD). Other symbols were not tested.


How to use:

1. Copy H4BreakoutRetest_XAU.mq5 into the MQL5\Experts folder of your terminal (File - Open Data Folder) and compile it in MetaEditor.

2. Attach the EA to a gold chart (any timeframe) and enable AutoTrading.

3. Load one of the attached presets from the Inputs tab (Load) or set AllowStacking as you prefer.

4. Test it on the Strategy Tester and on a demo account before anything else.

MACrossoverEA MACrossoverEA

Il sistema apre le posizioni quando le due medie mobili (Fast e Slow) si incrociano. Funziona su qualsiasi strumento e su qualsiasi timeframe.

MarketInfo MarketInfo

MarketInfo è un semplice script informativo per MetaTrader 5. Raccoglie e registra nel log i dati chiave relativi al simbolo corrente: prezzi, spread, volatilità (ATR), tempo rimanente alla chiusura della candela, statistiche su N candele e identificazione del trend.

Heiken Ashi ATR Blend Heiken Ashi ATR Blend

Heiken Ashi ATR Blend combina candele Heiken Ashi smussate, un filtro di volatilità basato sull'ATR e la conferma del trend tramite EMA veloce/lenta per identificare potenziali segnali di inversione di tendenza.

Spread Monitor migliorato Spread Monitor migliorato

Spread Monitor è un semplice indicatore informativo per MetaTrader 5. Visualizza lo spread attuale in punti sotto forma di un pannello grafico compatto con indicazione cromatica e una barra di livello.