Join waitlist
Strategies / Pattern / Fair Value Gap Break of Structure

Fair Value Gap Break of Structure

The strategy waits for a break of the last swing high or low, then looks for a fair value gap in that move. It buys or sells short when price returns into the gap, with a stop beyond it and a target at 2 ATR.

PatternLong & shortSwingSilver4 hours
1.81Profit factor
173,562Net profit USD
35.21%Win rate
2,073Trades
-17,838Max drawdown
83.73Avg trade

Best run of 3. Silver, 4 hours, spread 2, from run pf:2026-10-04-SILVER-4h.tsv:3.

Entry rules, long

  1. A bullish break of structure is a close above the last swing high, a pivot confirmed by 10 bars on each side.
  2. A bullish gap forms when the low is above the high from 2 bars earlier, within 20 bars of a bullish break of structure.
  3. The gap zone runs from the high 2 bars earlier up to the current low.

Entry rules, short

  1. A bearish break of structure is a close below the last swing low, a pivot confirmed by 10 bars on each side.
  2. A bearish gap forms when the high is below the low from 2 bars earlier, within 20 bars of a bearish break of structure.
  3. The gap zone runs from the low 2 bars earlier down to the current high.

Exit rules

  1. The target is 2 times ATR(14) from the entry fill.
  2. Positions close at the stop or target, whichever is hit first.

Test conditions

PeriodUp to 2026-10-04
InstrumentSilver, 4 hours
Spread2 points
Starting capital1,000,000
CostsSpread only. Commissions and overnight financing are not included.
BarsUp to 200,000 bars, fewer where the instrument has less history
Last tested2026-10-04

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
SilverBest run4 hours1.81 2,07335.21173,562 USD-17,838
Dow Jones4 hoursn/a 74339.9713,777 EUR-6,447
Brent CrudeDailyn/a 44741.3912,300 EUR-5,212

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// Fair Value Gap Break of Structure
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Pattern
// Direction: Long & short
// Timeframe tested: 4 hours
// ==============================================================

DEFPARAM CumulateOrders = false

ONCE lastsh = 0
ONCE hassh = 0
ONCE lastsl = 0
ONCE hassl = 0
ONCE bosupbar = 0
ONCE hasbosup = 0
ONCE bosdnbar = 0
ONCE hasbosdn = 0
ONCE bfvgh = 0
ONCE bfvgl = 0
ONCE bfvgbar = 0
ONCE hasbfvg = 0
ONCE sfvgh = 0
ONCE sfvgl = 0
ONCE sfvgbar = 0
ONCE hassfvg = 0

atrval = AverageTrueRange[14](close)

67 more lines: the entry and exit rules.

Setup

How to load it

  1. Copy the code with the copy button on the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Indicators used

ATR
Read this firstKnown weaknesses2 points
  • Results include the spread only. Commissions and overnight financing are not included.
  • The code is published as it was backtested and has not been compiled again since.

Questions

About this strategy

Can I run Fair Value Gap Break of Structure in ProOrder?

Yes. The code is ProBuilder and runs as an automated ProOrder system. Backtest it on your own account with your own spread and position size before trading it live.

Which markets was it tested on?

It was tested on 3 market and timeframe combinations. The best run was Silver, 4 hours, with a profit factor of 1.81 over 2,073 trades.

How large was the drawdown?

The best run had a maximum drawdown of 17,838 USD at the tested position size, against a net result of 173,562 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

KDJ J Line Momentum Long

Uses the same indicator.

4.17 PF · 6,135 trades

SMA Crossover With RSI Exit

Best run on the same market, Silver.

2.13 PF · 8,999 trades

Stochastic Reversal With Average Spread

Also a pattern strategy.

1.81 PF · 236 trades

Get the full rules, the complete code and the ProRealAlgos portfolio as a member.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs