MarketStructure
Whether recent swing highs and lows form an uptrend (+1), a downtrend (-1) or a narrowing range (0).
MarketStructure marks swing points in the high and low prices: a swing high is a bar whose high is no lower than any high within lookback bars on either side, and a swing low is the mirror case for lows. It reads the last two swing highs and the last two swing lows: both rising gives +1, both falling gives -1, and highs falling while lows rise gives 0. The reading holds its last value until a new swing sets a clear pattern.
How to read it
- The line sits in its own pane below the price and only takes the values -1, 0 and +1, so it draws as a step line.
- +1 means the recent swing highs and swing lows both stepped up; -1 means both stepped down.
- 0 means the highs fell while the lows rose, so the range is narrowing and no clear trend has formed.
- A change shows up only after the swing it rests on is confirmed, which is lookback bars after the actual turn.
What it outputs
- Trend state
- Trend read from the last two confirmed swing highs and swing lows: 1 up, -1 down, 0 narrowing range. Holds its value between changes.
Settings
- lookback
- How many bars on each side a high or low must beat to count as a swing. Higher means only major swings count, so the trend changes less often and later. Lower, at 1 or 2, counts every small pivot, so the line flips often on noise.
Pitfalls
- The change is confirmed late: a swing is only known lookback bars after it forms, so the line moves after the turn, not at it.
- The line holds through choppy stretches: equal highs or lows, or a higher high with a lower low, keep the previous reading, so a faded trend can stay on the chart.
- It describes past structure only. Its correlation with the close was 0.12 in the sample, so it is a regime label, not a price level or a forecast.