# Order blocks

`order_blocks`

The last opposite candle before a break of structure, kept until price trades back through it.

## Inputs

| Name | Type | Default | Range |
| --- | --- | --- | --- |
| swing_len | int | 5 | 2 to 100 |
| internal_len | int | 2 | 1 to 99 |
| internal | bool | true |  |
| swing | bool | true |  |
| show_last | int | 5 | 1 to 5 |
| mitigation | choice | wick |  |
| break_on | choice | close |  |

## Outputs

| Name | Kind |
| --- | --- |
| swing_bull_1 | zone |
| swing_bull_2 | zone |
| swing_bull_3 | zone |
| swing_bull_4 | zone |
| swing_bull_5 | zone |
| swing_bear_1 | zone |
| swing_bear_2 | zone |
| swing_bear_3 | zone |
| swing_bear_4 | zone |
| swing_bear_5 | zone |
| internal_bull_1 | zone |
| internal_bull_2 | zone |
| internal_bull_3 | zone |
| internal_bull_4 | zone |
| internal_bull_5 | zone |
| internal_bear_1 | zone |
| internal_bear_2 | zone |
| internal_bear_3 | zone |
| internal_bear_4 | zone |
| internal_bear_5 | zone |
| bull_mitigated | event |
| bear_mitigated | event |

Warm-up: 0 bars (0 at the defaults).

Repaints: No.

## Formula

Breaks are found as in market structure, with swing_len, internal_len and break_on. For an upward break, Forge takes the lowest low between the broken swing high and the break bar; the order block is the last down candle (close below open) at or before that low, back to the swing high. Its box spans that candle's high and low. A downward break mirrors it with the last up candle.

A block is shown from the break bar on. A bullish block is mitigated and removed when price trades below its low (mitigation wick) or closes below it (mitigation close); a bearish block mirrors it. bull_mitigated and bear_mitigated mark the bar.

Internal and swing blocks are tracked apart and turned on or off by internal and swing. Slot 1 is the newest unmitigated block of its kind; show_last slots are shown. Forge keeps the five newest unmitigated blocks per kind.
