Market structure
Breaks of structure and changes of character from confirmed swing highs and lows.
Market structure from confirmed swing pivots (swing params as swing). The last unbroken swing high (low) is broken when the close (or the wick, break_on) passes it by max(floor_pct % × close, break_k × ATR); each pivot breaks once per direction. A break in the bias direction is a BOS, against it a CHoCH; the first break with no bias only sets the bias. Both levels broken on one candle: the candle's colour picks the one that counts. protected_level = the level whose break would flip the bias.
Market structure is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.
Settings
| Setting | Default | Range | What it does |
|---|---|---|---|
| atr_period | 14 | 1 to 500 | ATR length (Wilder) for every buffer. |
| swing_k | 2 | 0.1 to 20 | Swing reversal in ATRs: a pivot is confirmed when a close moves this far back. |
| swing_min_pct | 0.1 | 0 to 10 | Smallest swing reversal, % of the close. |
| break_on | close | close, wick | What must pass a swing level to break it. |
| break_k | 0 | 0 to 5 | A swing level is broken only this many ATRs beyond it. |
| floor_pct | 0 | 0 to 10 | Smallest buffer of this detector, % of the close (each buffer is the larger of this and its ATR multiple). |
What it gives
| Output | What it is |
|---|---|
| Bullish break of structure | True on a bullish break of structure. |
| Bearish break of structure | True on a bearish break of structure. |
| Bullish change of character | True on a bullish change of character. |
| Bearish change of character | True on a bearish change of character. |
| Bullish bias | True while the structure bias is bullish. |
| Bearish bias | True while the structure bias is bearish. |
| Protected level | The swing level whose break flips the bias (a low in a bullish bias). |
What it reads
It reads the whole candle (open, high, low, close and volume).
Warm-up
With its default settings, Market structure needs 241 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.
Test it
Copy this sentence into the Algonney chat to backtest it:
Backtest a strategy on BTC that uses Market structure with its default settings