MarketStructure

forge.taclassSince Forge API 1
Signaturepython
forge.ta.MarketStructure(**inputs: Any) -> None

Confirmed swings labelled HH, HL, LH and LL, with breaks of structure (BOS) and changes of character (CHoCH), for internal and swing structure.

Inputs

NameTypeDefaultRange
swing_lenint52 to 100
internal_lenint21 to 99
internalbooltrue
swingbooltrue
confluence_filterboolfalse
break_onchoiceclose

Indicator: Market structure

A swing high is a bar whose high is above the high of every bar within swing_len bars on each side; a swing low mirrors it. Equal highs make no swing. A swing is known swing_len bars after it, and every value is written on that later bar; the chart draws the label back on the swing bar.

HH and LH mark a swing high above or below the previous one; HL and LL mark a swing low above or below the previous one.

A break happens on the first bar that closes above the latest swing high (break_on close) or trades above it (break_on wick). It is a change of character (CHoCH) when the trend was down, and a break of structure (BOS) otherwise; the trend then turns up and that level cannot break again. Breaks below the latest swing low mirror it. Values +1 are upward breaks and -1 downward.

Internal structure applies the same rule with internal_len. internal and swing turn each one on or off. With confluence_filter on, an internal break is marked only when its bar closes in the break's direction and the level it breaks is not the swing level. A missing bar starts the structure again.