Summary
This article shows how to build a daily breakout setup based on a simple 3-candle swing high or swing low.
The idea:
Check the last 3 closed daily candles
If the middle candle is the highest, mark it as a swing high
Place a Buy Pending Order at that swing high
If the middle candle is the lowest, mark it as a swing low
Place a Sell Pending Order at that swing low
Delete the order at the end of the day if it was not triggered
Also known as: daily breakout, swing high breakout, swing low breakout, fractal breakout, previous high/low breakout.
This is an educational example, not investment advice. Always export and test in MT5 Visual Mode.
What the strategy does
The EA looks for a small fractal pattern using the last 3 closed candles.
For a swing high:
Candle High ID 2 > Candle High ID 1 Candle High ID 2 > Candle High ID 3
This means the middle candle is higher than the candle before and after it.
For a swing low:
Candle Low ID 2 < Candle Low ID 1 Candle Low ID 2 < Candle Low ID 3
This means the middle candle is lower than the candle before and after it.
Candle IDs used
Use closed candles only:
Candle ID 1 = last closed candle Candle ID 2 = candle before that Candle ID 3 = candle before that
For this setup, Candle ID 2 is the middle candle of the 3-candle pattern.
Buy logic
Use Run at Time once per day.
Example:
Run at Time: 01:00
Then check if Candle ID 2 is a swing high:
Candle High ID 2 > Candle High ID 1 Candle High ID 2 > Candle High ID 3
If both are true, place a Buy Pending Order at:
Custom Price Level → Candle High ID 2
Simple structure:
Run at Time: 01:00 → Trade Rule: Candle High ID 2 > Candle High ID 1 → Trade Rule: Candle High ID 2 > Candle High ID 3 → Buy Pending Order at Candle High ID 2
Sell logic
Use the same idea, but reversed.
Check if Candle ID 2 is a swing low:
Candle Low ID 2 < Candle Low ID 1 Candle Low ID 2 < Candle Low ID 3
If both are true, place a Sell Pending Order at:
Custom Price Level → Candle Low ID 2
Simple structure:
Run at Time: 01:00 → Trade Rule: Candle Low ID 2 < Candle Low ID 1 → Trade Rule: Candle Low ID 2 < Candle Low ID 3 → Sell Pending Order at Candle Low ID 2
Order expiration
Do not leave old pending orders active forever.
Set the pending order to expire or auto-delete near the end of the trading day.
Example:
Delete pending order at 21:00
This keeps the logic clean:
At 01:00, the EA checks for a new swing high or swing low
It places a pending order if the setup exists
If the order is not triggered by 21:00, it gets deleted
The next day starts fresh
Main blocks used
Run at Time
Runs the setup check once per day.
Trade Rule
Checks whether Candle ID 2 is higher or lower than the surrounding candles.
Buy Pending Order
Places a buy order at the swing high.
Sell Pending Order
Places a sell order at the swing low.
Order expiration / Delete Pending Orders
Removes old pending orders if they are not triggered during the day.
Make it your own
You can adjust:
The stop loss placement
The take profit, for example 2R, 3R, or 5R
Whether the target is fixed or trailing
The order expiration time
A larger fractal pattern, for example 5 candles instead of 3
Inputs for stop loss and take profit so you can test different values in MT5
Draw on Chart blocks to mark the swing high and swing low visually
For a 5-candle swing high, the middle candle would be Candle ID 3:
Candle High ID 3 > Candle High ID 1 Candle High ID 3 > Candle High ID 2 Candle High ID 3 > Candle High ID 4 Candle High ID 3 > Candle High ID 5
Conclusion
This setup uses a simple swing high or swing low as a breakout level.
The core logic is:
Find 3-candle swing high/low → Place pending order at the swing level → Delete the order if not triggered → Repeat the next day
Export and test in MT5 Visual Mode to confirm the candle IDs, order level, and expiration timing work correctly.
