Skip to content
All strategies

Strategies

BreakdownLevelDay (Khlystov / barabashkakvn) on spot gold: previous-trading-day high/low OCO stop breakout with fixed-percent SL/TP, XAUUSD.SPOTMETAL 1-HOUR

Outcome: Backtesting

XauBreakdownLevelDay

BreakdownLevelDay (Khlystov / barabashkakvn) on spot gold: previous-trading-day high/low OCO stop breakout with fixed-percent SL/TP, XAUUSD.SPOTMETAL 1-HOUR

Hypothesis

Derived by the Research Lead from "BreakdownLevelDay" by MQL5 Code Base (library) https://www.mql5.com/en/code/17058: From the source: previous-day high/low Buy/Sell Stop pair placed at TimeSet 00:00, OCO cancellation, fixed SL/TP, no breakeven or trailing, and defaults Delta 6 / SL 2000 / TP 2000 read from the author's screenshot. Research Lead choices: XAUUSD.SPOTMETAL 1h instead of the EURUSD-type chart, trading day = SPOTMETAL session, points converted to % of price (0.004% / 1.4% / 1.4%), equity-relative 1x……Show moreShow less

Derived by the Research Lead from "BreakdownLevelDay" by MQL5 Code Base (library) https://www.mql5.com/en/code/17058: From the source: previous-day high/low Buy/Sell Stop pair placed at TimeSet 00:00, OCO cancellation, fixed SL/TP, no breakeven or trailing, and defaults Delta 6 / SL 2000 / TP 2000 read from the author's screenshot. Research Lead choices: XAUUSD.SPOTMETAL 1h instead of the EURUSD-type chart, trading day = SPOTMETAL session, points converted to % of price (0.004% / 1.4% / 1.4%), equity-relative 1x sizing instead of a fixed lot, OpenStop=false under netting, daily cancel-and-replace of unfilled orders. Port of the MQL5 Code Base Expert Advisor 'BreakdownLevelDay' (idea by Vladimir Khlystov, MQL5 code by barabashkakvn, https://www.mql5.com/en/code/17058). The EA trades daily breakouts with pending orders. At TimeSet it places a Buy Stop at the day's high + Delta and a Sell Stop at the day's low - Delta, each with fixed SL and TP. When one fills, the other is deleted. With TimeSet = 00:00 it trades the breakout of the PREVIOUS day. The source figures (MT terminal screenshots, EURUSD-like 1.43-1.50 prices, H1 bars, 4-12 Feb 2009) show the tested settings: TimeSet 00:00, Delta 6, SL 2000, TP 2000, Lot 0.10, risk 0, NoLoss 0, trailing 0. The charts mark one buy-stop/sell-stop pair at each midnight (dashed day separators), fills at the prior day's extremes, and SL/TP exits about 200 pips (~1.4% of price) from entry. The third attachment is an MQL5 Freelance banner with no trading content. The source is an FX EA, and we have no FX majors. Spot gold XAU/USD (XAUUSD.SPOTMETAL) is the closest supported OTC/FX-style 24x5 market with a daily session, and it is almost unused in the corpus (1 of 4,319 experiments). Adaptations: (1) 'Day' = the SPOTMETAL trading day (18:00 to 17:00 New York; use session_date_of, never a calendar date). TimeSet 00:00 maps to the session open: on the first 1-HOUR bar of each new trading day, read the completed previous trading day's high and low from the 1h bars. (2) Point distances become percentages of price: Delta 6 points on a 5-digit ~1.45 quote = 0.004% and becomes delta_pct = 0.004%. SL/TP 2000 points = 0.0200 on ~1.45 = 1.38% and becomes sl_pct = tp_pct = 1.4% from the fill price. (3) Fixed lot (risk=0) becomes equity-relative sizing: notional = 100% of equity (leverage 1.0), so one SL hit costs ~1.4% of equity. (4) NoLoss and trailing stay disabled, matching the figure. (5) OpenStop is not shown in the figure, and the account is netting (hedge_mode unsupported), so OpenStop = false: no new pending pair is placed while a position is open. The screenshot shows overlapping hedged positions; those cannot be expressed here, and only one net position exists at a time. (6) Unfilled pending orders are cancelled and replaced at the next trading-day open (the EA re-places them every day at TimeSet). Execution: the entry stops are platform-matched intrabar stop_market orders (capability intrabar_stop: supported), not exchange-hosted. SL/TP are an intrabar reduce-only stop plus a take-profit limit (a bracket) attached on fill. When one entry stop fills, the opposite one is cancelled (OCO). If a single 1h bar touches both stops, the engine's adaptive OHLC ordering decides, and the second order is cancelled as soon as the first fills. Overnight financing on SPOTMETAL (long pays fed funds + 2.5%/yr, short receives fed funds - 2.5%/yr, Wednesday x3) is charged by the platform and is part of the test. Fee arithmetic: RT cost ~0.015% spread plus ~0.02% per night held. With symmetric 1.4% SL/TP, the break-even win rate is ~51.3% including costs. The edge needs only a slight continuation bias after a prior-day extreme breaks: a 53% hit rate gives ~+0.08% per trade gross of financing and ~+0.05-0.06% net, about 4x the round-trip cost.

Spot gold is the closest supported market to the FX instrument in the source and is almost unused in the corpus (SPOTMETAL 0.0%). It also adds long+short (direction bucket 79% long-only) and keeps away from the over-mined BINANCE (55%) and the BCH/LTC Hyperliquid trend-follower graveyard. The mechanism is a session-anchored prior-day-extreme stop breakout with fixed brackets, not a moving-average crossover.

Implementation

MQL5 BreakdownLevelDay port on XAUUSD.SPOTMETAL 1h: at each SPOTMETAL trading-day completion, an OCO Buy Stop at prior-day high*(1+delta%) and Sell Stop at prior-day low*(1-delta%); on fill, OUO reduce-only SL stop and TP limit at sl_pct/tp_pct from the fill price. No breakeven/trailing; no new pair while a position is open; unfilled stops cancelled and replaced daily. 1x equity notional.

Iteration 2 fix for Layer 2: the linked OCO entry pair and OUO SL/TP pair are built as StopMarketOrder/LimitOrder objects (the order factory cannot set contingency links), which require the registered trader_id. The Layer-2 proxy has no trader (trader_id None), so these builders now return early when trader_id is None. Under the real engine (Layer 3, backtest, paper) trader_id is always set, so trading logic is unchanged. Signal logic and everything else are untouched.

Verification Results

Query orders_open() and orders_inflight() for this instrument and strategy, deduplicate by client_order_id, and inspect only working orders.

_my_orders() queries cache.orders() and then filters closed orders. This scans the accumulated order history on every bar and multiple times on fills, so execution cost grows with the backtest's lifetime despite the scalar range calculation. The short sandbox does not measure this full-history cost.

Iteration History

Verification failed (Layer 2 — synthetic scenarios): Parameters used: ['sl_pct', 'tp_pct', 'no_loss', 'trailing', 'delta_pct', 'open_stop', 'min_notional', 'day_definition', 'notional_fraction', '_optimization_plan', 'cancel_unfilled_at_next_day_open'] Check that __init__ sets all attributes from self.parameters.get(). - steady_uptrend: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - steady_downtrend:……Show moreShow less

Verification failed (Layer 2 — synthetic scenarios): Parameters used: ['sl_pct', 'tp_pct', 'no_loss', 'trailing', 'delta_pct', 'open_stop', 'min_notional', 'day_definition', 'notional_fraction', '_optimization_plan', 'cancel_unfilled_at_next_day_open'] Check that __init__ sets all attributes from self.parameters.get(). - steady_uptrend: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - steady_downtrend: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - flat_ranging: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - volatility_spike: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - zero_volume: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000) - price_gap: TypeError: Argument 'trader_id' has incorrect type (expected nautilus_trader.model.identifiers.TraderId, got NoneType) (bar timestamp: 1735941600000)

Analysis

BreakdownLevelDay

Analysis

Creating an Order - Freelance service at MQL5.com

Backtest and paper results are hypothetical. Trading involves risk of loss.