- Strategy
- Buys when a candle closes above the latest swing high in an uptrend and price then retests the broken level and closes back above it; sells on the mirror image below a swing low.
- Risk model
- 1% of balance per trade (configurable), stop-loss on every order, one position per symbol and magic number
What it does
Structure Break EA turns a common price-action idea into fixed rules: when price closes beyond the most recent swing high or low, the old level often acts as support or resistance on the way back. The EA waits for that break, then waits again for price to return to the level, and only enters when the retest candle closes back in the break direction.
It trades one position at a time per symbol and magic number, always with a stop-loss, and sizes every trade from your risk percentage.
How it works
On every new bar the EA reads closed candles only:
- A swing high is a bar whose high is above the highs of the N bars on each side (N = swing strength); a swing low is the mirror image. The latest confirmed swing of each kind is used.
- A bullish break of structure happens when the last closed candle closes above the latest swing high and the candle before it did not. If the trend filter is on, that close must also be above the 200 EMA. Each swing can trigger only once.
- For up to the set number of bars, the EA waits for a retest: a candle whose low comes within the tolerance (0.2 ATR by default) of the broken level and which closes above it. A close back below the level minus the tolerance cancels the setup.
- On a valid retest it buys at market. The stop goes below the lower of the retest low and the level, minus a 0.3 ATR buffer. The take-profit is 2 R by default.
Sells follow the same rules below swing lows. Optional break-even and ATR trailing manage the open trade on every tick.
How to use it
The EA suits trending markets on M15 to H4. A higher swing strength finds fewer, more significant levels; a lower value reacts faster but trades more noise. Keep the trend filter on unless you want counter-trend breaks too. Check the Experts tab: the EA prints every detected break, cancellation and skip reason, which makes it easy to compare its decisions with the chart.
Settings
| Input | Default | What it changes |
|---|---|---|
| Swing strength | 3 | Bars on each side needed to confirm a swing |
| Lookback bars | 150 | How far back the EA searches for swings |
| Retest bars | 12 | Time allowed for the retest |
| Retest tolerance (x ATR) | 0.2 | Distance counted as touching the level |
| Stop buffer (x ATR) | 0.3 | Extra room beyond the retest candle |
| Max stop (x ATR) | 3.0 | Skips trades with very wide stops |
| Trend EMA | on, 200 | Direction filter |
| Risk % / Fixed lots | 1.0 / 0 | Position sizing |
| Take-profit (R) | 2.0 | Target distance (0 = none) |
| Max spread (points) | 30 | Skips entries when spread is wider |
| Trading hours | 7 to 20 server time | Window for new entries |
| Break-even / Trailing | on at 1 R / off | Trade management |
Limitations
Swing points are only confirmed after N bars, so breaks are recognised with a delay. In ranging markets price breaks and reverses often, which produces cancelled setups and losing retests. Fast markets can retest beyond the tolerance and never trigger an entry. Results depend on spread and on your broker's data.
Before you run it live
Run the EA on a demo account and in the Strategy Tester (with "Every tick based on real ticks" where available) across several months and symbols. Check your broker's stops level, spread and trading hours, and set the server-time hours to match. Start with a small risk percentage, and use the Position Size Calculator to understand what 1% means on your account. Trading on margin carries a substantial risk of loss.

