Market structure

market_structuresmart_moneyForge API 1

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

Outputs

NameTypeRequiredDescription
boseventOptionalcolor_down theme.down, color_up theme.up, shape circle, style marker, where above_bar
chocheventOptionalcolor_down theme.down, color_up theme.up, shape triangle_up, style marker, where above_bar
internal_boseventOptionalcolor_down theme.down/0.60, color_up theme.up/0.60, shape circle, style marker, where above_bar
internal_chocheventOptionalcolor_down theme.down/0.60, color_up theme.up/0.60, shape triangle_up, style marker, where above_bar
hhvalueOptionalcolor theme.up, shape triangle_down, shift -5, style marker, where above_bar
lhvalueOptionalcolor theme.down, shape triangle_down, shift -5, style marker, where above_bar
hlvalueOptionalcolor theme.up, shape triangle_up, shift -5, style marker, where below_bar
llvalueOptionalcolor theme.down, shape triangle_up, shift -5, style marker, where below_bar
swing_highvalueOptionalcolor theme.down, dash dot, style step, width 1
swing_lowvalueOptionalcolor theme.up, dash dot, style step, width 1
internal_highvalueOptionalcolor theme.accent, style line, width 1
internal_lowvalueOptionalcolor theme.accent, style line, width 1
trendvalueOptionalcolor theme.accent, style line, width 1
internal_trendvalueOptionalcolor theme.accent, style line, width 1
Warm-up
2 * internal_len bars (4 at the defaults)
Repaints
Yes
Parity
None

Formula

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.