Skip to content
All library documents

Swing-Structure Breakouts with Opposing Hedge Entries

Article TradingView scripts

Summary

This strategy identifies pivot highs and lows using a configurable lookback on both sides of a candidate swing. It compares successive swing points to label higher highs and higher lows as an uptrend, or lower highs and lower lows as a downtrend. In an uptrend, a close above the prior swing high can trigger a primary long; in a downtrend, a close below the prior swing low can trigger a primary short. A break of the opposing structural level can trigger a smaller countertrend hedge, which may be closed if price retraces. Optional fixed-percentage stops and targets manage primary positions, while hedge entries use stops when that setting is enabled.

The code plots swings, structure, and trade information, but supplies no measured results or evidence that hedging improves risk-adjusted returns. Pivot identification requires later bars to confirm a turning point, so signals arrive with delay. The hedging, position flags, and net-position handling are implementation-specific and merit careful inspection before interpreting a backtest; costs, slippage, and sizing also affect outcomes.

Key ideas

  • Pivot highs and lows are compared to classify market structure as rising, falling, or neutral.
  • Breakouts beyond swing levels trigger primary entries in the direction of the classified trend.
  • A break against the prevailing structure can open a limited opposing hedge position.
  • Hedges may close when price retraces across the relevant prior swing level.
  • The script includes optional percentage stops and targets, but reports no performance evidence.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.