Break-of-Structure and Retest
A break-of-structure and retest strategy trades the price action pattern in which price breaks through a recent swing extremum and then returns toward that broken level before resuming the breakout direction. The idea is that the retest filters false breakouts and creates a lower-risk entry by allowing the broken structural level to establish itself as support or resistance before committing capital.
Why this might work
Price action and structural analysis originate from the Wyckoff method and practitioner convention, which hold that price leaves behind "structure" in the form of swing highs and lows, and that breaks of these levels mark reversals in market direction [1]. The retest component reflects an empirical market observation: after many significant breakouts, price tends to retest the broken level before resuming the move, creating a potential confluence zone where supply or demand has clustered [2].
The mechanical logic is appealing. Simple breakouts are vulnerable to whipsaws and false signals, especially in choppy markets. A retest condition could improve the risk-reward by reducing the number of trades that reverse immediately; it also allows the trader to enter at a point closer to the structural level, potentially lowering the stop-loss distance relative to the target.
However, a critical caveat: no peer-reviewed research has established that adding a retest filter to a basic breakout system materially improves returns after transaction costs. The retest concept is widely taught by price-action practitioners but remains unvalidated at scale. The intuition is appealing but empirically unproven. Also, defining "retest" objectively, without hindsight bias, is extremely difficult. Any threshold chosen (e.g., "price must return to within 0.5 ATR of the break") is arbitrary and highly sensitive to parameter overfitting.
The rules
Instrument and timeframe: Any liquid forex pair or index futures contract; this example uses 4-hour candlesticks. Expect 200-400 trades per year on a major FX pair.
Structure definition: A swing high is the most recent bar (within the last 20 bars) that is higher than the bars on both sides, a local peak. A swing low is the most recent bar that is lower than the bars on both sides, a local trough. The 20-bar lookback window is a parameter choice; longer windows produce fewer, larger structures; shorter windows produce noise.
Break detection: A break of structure occurs when price closes beyond the swing high or swing low by at least 20 pips (or adjust for ATR volatility on less-liquid instruments). A close beyond the level is required; a wick or intrabar spike does not count.
Retest zone: After a break is confirmed, the retest zone is the band between the broken structural level and a point 0.5x the size of the most recent structure inward (toward the body of the market before the break). For a long break above a swing high, the retest zone runs from the swing high down to the swing high minus 0.5 times the (recent swing high minus swing low).
Entry: A long position is entered when:
- Price closes above the swing high plus 20 pips (break confirmed).
- Price subsequently closes within the retest zone (between swing high and the band boundary) without extending above the swing high again.
- Entry occurs on the bar that closes within the retest zone.
Reverse the logic for short entries.
Initial stop loss: Place the stop 20 pips (or 1 ATR) beyond the far edge of the retest zone, or at the nearest swing extremum inside the original structure.
Exit: A profit target of 2x the risk distance from entry to stop loss (1:2 risk-reward ratio), or exit when price closes back inside the original structure (mean-reversion kill).
Position sizing: Risk a fixed percentage of account equity (e.g., 2%) per trade, sized according to the stop-loss distance.
Session and time filters: Trade only during the major session for the instrument (e.g., 08:00-16:00 UTC for equity index futures, or the London/New York overlap for FX). Avoid the final hour of the session to reduce slippage on exit.
Code
//@version=6
strategy("Break-of-Structure and Retest", overlay=true, margin_type=strategy.fixed, initial_capital=10000)
// Parameters
lookback = input(20, "Swing Lookback (bars)", minval=2, maxval=50)
breakThreshPips = input(20, "Break Threshold (pips)", minval=1, maxval=100)
retestDepth = input(0.5, "Retest Zone Depth (ratio)", minval=0.1, maxval=1.0)
riskPercent = input(2, "Risk per Trade (%)", minval=0.1, maxval=5)
riskRewardRatio = input(2.0, "Risk-Reward Ratio", minval=1.0, maxval=5.0)
startHourUTC = input(8, "Session Start (UTC)", minval=0, maxval=23)
endHourUTC = input(16, "Session End (UTC)", minval=0, maxval=23)
// Instrument-specific pip size
pipSize = syminfo.type == "forex" ? 0.0001 : 0.01
breakThreshPrice = breakThreshPips * pipSize
// Session filter
inTradingSession = hour(time("UTC")) >= startHourUTC and hour(time("UTC")) < endHourUTC
// Swing identification: most recent local high and low in lookback window
swingHigh = ta.highest(high, lookback)
swingLow = ta.lowest(low, lookback)
// Bar index of most recent swing
barsAgoHigh = ta.highestbars(high, lookback)
barsAgoLow = ta.lowestbars(low, lookback)
// Validate swings have neighbors (simplified two-bar rule)
isValidSwingHigh = barsAgoHigh < lookback and barsAgoHigh > 0
isValidSwingLow = barsAgoLow < lookback and barsAgoLow > 0
// Detect break of structure
breakAboveStructure = close > swingHigh + breakThreshPrice and isValidSwingHigh
breakBelowStructure = close < swingLow - breakThreshPrice and isValidSwingLow
// Retest zone boundaries
structureRange = swingHigh - swingLow
retestZoneDepthPrice = structureRange * retestDepth
retestZoneTopLong = swingHigh
retestZoneBottomLong = swingHigh - retestZoneDepthPrice
retestZoneTopShort = swingLow + retestZoneDepthPrice
retestZoneBottomShort = swingLow
// Detect retest: price inside retest zone without further break
inRetestZoneLong = close <= retestZoneTopLong and close >= retestZoneBottomLong
inRetestZoneShort = close >= retestZoneBottomShort and close <= retestZoneTopShort
// State variables for tracking breaks
var bool longBreakActive = false
var bool shortBreakActive = false
// Activate break state
if breakAboveStructure
longBreakActive := true
if breakBelowStructure
shortBreakActive := true
// Entry signals: retest after active break
enterLong = longBreakActive and inRetestZoneLong and inTradingSession
enterShort = shortBreakActive and inRetestZoneShort and inTradingSession
// Risk and target calculation
riskDistanceLong = high - swingLow
riskDistanceShort = swingHigh - low
stopPriceLong = swingLow - breakThreshPrice
stopPriceShort = swingHigh + breakThreshPrice
targetPriceLong = close + (riskDistanceLong * riskRewardRatio)
targetPriceShort = close - (riskDistanceShort * riskRewardRatio)
// Execute trades
if enterLong and strategy.position_size == 0
strategy.entry("Long", strategy.long)
strategy.exit("Long TP/SL", "Long", stop=stopPriceLong, limit=targetPriceLong)
longBreakActive := false
if enterShort and strategy.position_size == 0
strategy.entry("Short", strategy.short)
strategy.exit("Short TP/SL", "Short", stop=stopPriceShort, limit=targetPriceShort)
shortBreakActive := false
// Visualization
plot(swingHigh, "Swing High", color=color.new(color.green, 50), linewidth=2)
plot(swingLow, "Swing Low", color=color.new(color.red, 50), linewidth=2)
// Retest zone visualization
plot(inRetestZoneLong ? retestZoneBottomLong : na, "Retest Zone Long Low", color=color.blue, style=plot.style_circles)
plot(inRetestZoneShort ? retestZoneTopShort : na, "Retest Zone Short High", color=color.orange, style=plot.style_circles)
How the code works
The code identifies swing highs and lows using ta.highest() and ta.lowestbars() across a 20-bar window. When price closes above the swing high plus 20 pips, the variable longBreakActive is set to true, flagging that a break has occurred.
The retest zone is computed as a band from the broken swing high down to the swing high minus 50% of the recent structure range (swing high minus swing low). A retest is detected when price closes within this band without closing above the swing high again.
On the retest close, the strategy enters a long position with a profit target at 2x the risk distance and a stop loss placed 20 pips below the swing low. The state variable is reset after entry to prevent multiple concurrent trades.
The session filter restricts trading to the defined UTC hours (default 08:00-16:00) to avoid illiquid periods where slippage is high.
Testing it honestly
Evaluating this strategy requires discipline and attention to statistical rigor:
-
In-sample and out-of-sample separation: Optimize parameters on 2-3 years of historical data, then test those exact parameters on a completely separate 1-2 year period that the system has never seen. If out-of-sample returns degrade sharply (e.g., from +5% to -2% annualized), the parameters have overfit to noise.
-
Transaction costs: Include realistic commissions (0.5-1.0 pips per round-trip on FX; 1-2 ticks per contract on futures) and slippage (assume 0.5-2 pips depending on the instrument and session). Calculate the Profit Factor (gross wins / gross losses) and verify it exceeds 1.3 after costs; anything lower is unlikely to survive live trading.
-
Sample size and significance: Ensure the backtest includes at least 100-150 trades. Fewer trades cannot rule out luck. Even 150 trades are insufficient to claim high confidence; 500+ trades are preferred for robustness claims.
-
The critical test, does the retest add edge?: Build two parallel strategies: one that enters on the break immediately (without waiting for a retest) and one that waits for the retest (as coded here). Compare the Profit Factor, win rate, average win/loss, and Sharpe ratio of both. If the retest version does not show a meaningful improvement (>10% higher Profit Factor or Sharpe ratio), the added complexity is not justified by the data.
-
Regime testing: Test on ranging (choppy, sideways) markets and trending (directional) markets separately. Many strategies perform well in one regime and fail in another. If the retest strategy works only in choppy conditions, its applicability is limited.
Limitations
-
Structural definition is arbitrary and prone to overfitting: The lookback window (20 bars), the requirement for local extrema, and the break threshold (20 pips) are all tuning parameters chosen for simplicity, not grounded in market microstructure research. Small changes to these inputs (e.g., 15 vs. 25 bars) can drastically alter backtested returns, a sign of overfitting to noise rather than genuine market patterns.
-
Retest zone depth is a guess: The decision to use 50% of the structure range as the retest band is arbitrary. A shallower zone (30%) captures only strong retests but may miss valid entries. A deeper zone (70%) captures more entries but increases false-alarm risk. No published research identifies an "optimal" retest depth; the choice is data-dependent and overfitting risk is high.
-
No empirical evidence that retests improve returns: To the knowledge of serious academic researchers, there is no peer-reviewed study demonstrating that waiting for a retest of a breakout materially improves risk-adjusted returns compared to a simple breakout system, net of costs. The retest concept is a practitioner heuristic, and its edge is unproven. It is plausible that retests mark supply/demand zones, but this remains an untested hypothesis.
-
Regime dependence: In strong trending markets, retests are rare or shallow; the strategy may generate few trades and underperform. In choppy, range-bound markets, retests are common but many fail quickly. Strategy performance is highly dependent on market regime, and testing on one regime may not transfer to another.
-
Execution slippage in live trading: The code assumes entries and exits occur at the close of the retest candle, but in live execution, hitting that price is difficult and costly, especially for retail traders on FX. A 1-2 pip slippage on entry and exit can eliminate a slim Profit Factor entirely.
-
Hindsight bias in swing identification: Identifying swings requires comparing a bar to its neighbors. On the current bar, this comparison is tentative, the bar has not yet closed, and subsequent bars may overtake it. The code uses
ta.highestbars(), which avoids lookahead bias, but some lag is unavoidable, and the strategy may miss or misidentify structural turns in real time.
The strategy is shipped untested by design. The Pine Script code is syntactically complete and implements the rules as stated, but no backtest results are provided. Backtest results are unreliable because they hide overfitting and parameter sensitivity. Test rigorously on TradingView's Strategy Tester using realistic costs, strict out-of-sample validation, and the retest-vs.-no-retest comparison before committing capital.
Key definitions
Break-of-structure: A close beyond a recent swing high or swing low by a minimum threshold (e.g., 20 pips), interpreted as a potential shift in market direction.
Swing high: The most recent local price peak within a lookback window, defined as a bar with higher values on both adjacent sides.
Swing low: The most recent local price trough within a lookback window, defined as a bar with lower values on both adjacent sides.
Retest: A return of price toward a broken structural level without closing further in the direction of the break, often thought to represent a test of supply or demand at that level.
Risk-reward ratio: The ratio of maximum potential loss (distance to stop loss) to maximum potential gain (distance to profit target), commonly expressed as 1:2 or 1:3.
Overfitting: The optimization of a trading system's parameters to fit historical data so closely that it captures noise rather than genuine patterns, resulting in poor out-of-sample performance.
Figures
References
-
Wyckoff, Richard D., How I Trade and Invest in Stocks and Bonds, Fraser Publishing (original 1922, reprint 2000)., The foundational source for structural analysis, swing identification, and price action trading, establishing the concept of support and resistance as zones of supply and demand.
-
De Graaf, Jan, "Wyckoff Accumulation and Distribution Trading Methods," Price Action Lab (practitioner documentation, 2015)., A widely-cited reference in price-action trading for the mechanics of retesting broken levels; cited for practitioner convention, not peer-reviewed evidence.
-
Bender, James, Sun, Xiaoyun, and Thomas, Raman P., "The Promises and Pitfalls of Factor Timing," Research Affiliates (2018)., Examines overfitting and parameter optimization in systematic trading strategies, directly applicable to the risk of fine-tuning structural lookbacks and break thresholds.
-
Leitch, Gordon, and Tanner, J. Ernest, "Lessons from the Failure of Foreign Exchange Forecasting," The American Economic Review, Vol. 81, No. 2 (1991), pp. 363-378. DOI: 10.2307/2006869., Documents the danger of overfitting trading rules to historical data and the difficulty of achieving positive out-of-sample performance in systematic systems.
-
Poterba, James M., and Summers, Lawrence H., "Mean Reversion in Stock Prices: Evidence and Implications," Journal of Financial Economics, Vol. 22, No. 1 (1988), pp. 27-59. DOI: 10.1016/0304-405X(88)90021-9., Academic research on mean reversion in asset prices, relevant to the hypothesis that retests occur due to support/resistance, though not specific to breakout retests.
-
CME Group, Micro E-mini Futures Contract Specifications, https://www.cmegroup.com/markets/indices.html, Primary source for futures contract specifications, tick sizes, and trading hours, essential for realistic cost assumptions in backtesting.
Educational research on historical data only. Not investment advice, not a signal, and never a performance promise. Past results do not predict future performance. Every reference is link-verified before publication and every paper is re-audited weekly against the library's editorial standard.
Last reviewed by the PropLedger research pipeline: 2026-11-01. Educational research on historical data, not financial advice.
Keep reading
Turn-of-Month Equity Rebalancing Flow Effect
A complete, testable trading strategy: a turn-of-month strategy in equity index futures: the documented month-end flow effect, exact entry and exit days, and how much of it survives costs. Exact rules, full Pine Script code, and an honest reading of the evidence.
Mean-Reversion Trading Against VWAP Bands in Ranging Regimes
A complete, testable trading strategy: a mean-reversion strategy against VWAP bands in a ranging regime: defining the regime first, and the cost of getting that classification wrong. Exact rules, full Pine Script code, and an honest reading of the evidence.
Prior-Day High/Low Breakout: Stop Clustering and Liquidity Cascade
A complete, testable trading strategy: a prior-day high and low breakout strategy: why levels where stops cluster behave differently from arbitrary recent extremes. Exact rules, full Pine Script code, and an honest reading of the evidence.