Auto Trendlines & Market Structure — MTF: Structure From Confirmed Pivots

Drawing a trendline is easy. Deciding which swings deserve to anchor it is the subjective part. Auto Trendlines & Market Structure — MTF is a free, open-source TradingView overlay that builds one resistance line and one support line from confirmed swing pivots, checks each candidate against older structure, and keeps retired lines as a visible historical trail. It adds a seven-state structure read and a higher-timeframe comparison panel without presenting any of them as a price forecast.

Auto Trendlines and Market Structure on a BTCUSD 15-minute chart, showing a validated resistance line through confirmed pivot highs, earlier dashed structure, pivot markers, and a multi-timeframe structure panel
A live TradingView preview: the bright line is active, dashed lines preserve earlier structure, and the panel describes the chart and higher timeframes without turning the read into a trade call.

Two active lines, with the discarded history still visible

Resistance is built from the two newest confirmed pivot highs; support uses the two newest confirmed pivot lows. Only the current pair stays bright, rendered as a solid core with a wider glow. When a newer pivot pair replaces a line, or when price invalidates it, the old line stops extending and freezes as a dashed reference.

That lifecycle matters when reviewing a chart in hindsight. The tool does not quietly drag an old anchor to a more convenient swing. You can see where earlier boundaries were, when they stopped being current, and how the new structure took over. The historical layer is capped in the code so it remains context rather than permanent chart clutter.

A two-point fit has to survive older pivots

The newest two pivots are only the starting candidate. Before a resistance line becomes active, the script checks up to four older pivot highs; support is checked against older pivot lows. A candidate is rejected if an older pivot contradicts it by more than 0.3 ATR. This tolerance and the number of checked pivots are defined in the Pine source, not inferred from a screenshot.

The check does not prove that a line will hold. It answers a narrower and more useful question: does the neat line through the newest pair already conflict with confirmed structure sitting behind it? If it does, the overlay leaves that candidate inactive.

Seven structural states instead of a single trend label

The script normalizes each active line’s slope by ATR and combines the signs of the support and resistance slopes. The result is one of seven readable states:

  • Uptrend or Downtrend when both boundaries slope in the same direction.
  • Expanding when resistance rises while support falls.
  • Contracting when resistance falls while support rises.
  • Range when neither slope clears the directional threshold.
  • HH Trending or LL Trending when only one validated boundary is active.

Strength is shown separately as Weak, Moderate, Strong or Very Strong. That separation prevents a common reading error: “Expanding” describes the relationship between the boundaries; it does not mean the same thing as a strong directional trend.

For a phase-based view built around regression rather than pivot-to-pivot boundaries, compare the Trend Channel Navigator. For qualified impulse legs and correction zones, see Impulse Waves & Reversal Zones.

What counts as a break

A wick through a line does not retire it. The source invalidates resistance only when a confirmed close finishes more than 0.5 ATR above the projected line; support uses the mirrored condition below. At that point the active line freezes at the break bar and the optional structure-break alert can fire.

This is structural invalidation, not a promise that price will continue after the close. The alert reports a chart event. It does not place an order, specify risk, or label the event as a buy or sell instruction. The distinction is the same one explained in our guide to structural breaks and invalidation.

The MTF panel uses closed higher-timeframe data

The panel shows the chart’s current class and strength, the active line values, channel width when both lines exist, and three automatically selected higher-timeframe rows. Those higher-timeframe rows request the prior closed higher-timeframe values with lookahead disabled. The tradeoff is deliberate: an HTF row can be one higher-timeframe bar behind the still-forming candle, but it does not rewrite its historical reading after that bar closes.

Confirmed pivots also have an unavoidable delay: a swing can only become a pivot after the lookback window has passed. That is not a defect hidden by the interface; it is the cost of anchoring lines to confirmed swings. Our broader non-repainting indicator guide explains why confirmation delay and live-bar movement should be discussed separately.

Settings verified against the Pine source

The settings are intentionally compact:

  • Pivot Lookback Mode defaults to Adaptive. The source clamps the adaptive window from five to ten bars based on ATR relative to price. Fixed mode exposes a lookback from three to fifteen bars and defaults to five.
  • Show Trend Lines, Show Channel Fill, Show MTF Panel, Show Pivot Markers, Show Trend Status and Show Line Labels independently control the visual layers.
  • Line Width (Core) ranges from one to five and defaults to three; the glow is rendered seven pixels wider than the core.
  • Alert on Trend Change and Alert on Trendline Break are both off by default. When enabled, their conditions remain gated to confirmed bars.

There are no user inputs for changing the validation tolerance, the confirmed-close break tolerance, or manually choosing the three higher timeframes in this version. If a setting is not listed above, do not assume the indicator exposes it.

Honest limitations

This overlay standardizes one way of drawing and classifying structure; it does not make that structure predictive. Pivot confirmation introduces delay. ATR normalization makes slope easier to compare across markets, but it does not make different instruments behave alike. A confirmed close beyond a line says the line was invalidated under the script’s rule, not that the next move is known.

The panel also does not evaluate transaction costs, liquidity, position size or any trading plan. Use it to keep line selection and structural labels consistent, then apply independent analysis to whatever decision comes next.

FAQ

Is Auto Trendlines & Market Structure — MTF free?
Yes. The live TradingView page identifies it as an open-source script and makes it available to use on a chart.

Does it draw buy and sell signals?
No. It draws structural boundaries, class labels and confirmed-bar change alerts. These are chart events, not trade instructions.

Why did a trendline appear after the swing?
Pivots are confirmed only after the selected lookback window has passed. The delay prevents the script from treating an unfinished swing as a finished anchor.

Can I choose the higher timeframes manually?
Not in the current Pine source. The panel selects three higher timeframes automatically from the chart timeframe.

Where can I inspect the indicator?
Open the free script on TradingView from the button below. Because it is open-source, its published Pine code can be reviewed directly.

Get the indicator — and the full guide

The full written guide — every setting explained, alert setup and worked chart examples — is free with an MQLSoftware account.

Analytical charting tools only. Nothing on this page is financial advice, a trading signal service, or a promise of results. All percentages are observed frequencies from specific charts and periods; they describe the past, not the future. Trading involves substantial risk of loss.
Log in ›