OPEN-SOURCE SCRIPT

AUTO TRENDLINE PRO

3 404
auto trendline pro

auto trendline pro is an automatic trendline indicator designed to display multiple degrees of market structure at the same time: live trendlines, confirmed trendlines, and higher timeframe trendlines.

the purpose of the tool is to help traders identify dynamic support and resistance lines, projected levels, confirmed breaks, and higher timeframe structure directly on the chart.

the indicator uses pivot points, wick or body anchors, atr-based validation, touch detection, duplicate filtering, forward projection, optional channels, and a dashboard for fast market reading.

it can be used for scalping, intraday trading, swing trading, and macro analysis depending on the selected settings.

---

inputs guide

degrees

live degree
enables live trendlines. this mode reacts faster to recent price action, but it can repaint because the pivots are still developing. it is useful for short-term market reading and early structure detection.

confirmed degree
enables confirmed trendlines. this mode is more stable because it uses confirmed pivots. it is recommended for cleaner analysis and more reliable structural levels.

htf degree
enables higher timeframe trendlines. this mode brings larger market structure into the current chart and helps identify major dynamic support and resistance levels.

anchor source
selects how the trendline anchors are calculated.
wick uses candle highs and lows.
body uses candle open and close extremes.
wick is more aggressive and reacts to full price extremes. body is cleaner and can reduce noise.

---

pivot strength

live pivot l/r
controls the strength of live pivots. a lower value creates more reactive trendlines. a higher value creates fewer but cleaner lines.

confirmed pivot l/r
controls the strength of confirmed pivots. a higher value makes the confirmed trendlines more selective and more structural.

htf pivot l/r
controls the pivot strength used on the higher timeframe. higher values create more macro-level lines.

---

htf source

htf timeframe
selects the higher timeframe used for htf trendlines. examples: 4h, 1d, 1w. higher timeframes provide stronger macro structure.

htf ath/atl window
defines the lookback window used to detect higher timeframe highs and lows. a larger value allows the indicator to anchor lines to more important historical extremes.

anchor htf line at ath / atl
allows htf lines to be anchored from the highest high or lowest low inside the selected htf window. this is useful for long-term trendlines and cycle analysis.

htf compute in log space
calculates htf trendlines using logarithmic logic. this is useful for assets with large percentage moves, such as crypto, because it gives a more balanced macro structure.

---

structure and validation

lines per side chart degrees
defines how many chart-degree lines are displayed per side. increasing this value shows more trendlines but can make the chart busier.

lines per side htf
defines how many higher timeframe lines are displayed per side. a lower value keeps the chart cleaner. a higher value gives more macro context.

new-anchor candidates
defines how many recent pivots are tested as possible new anchors. higher values test more combinations.

older-anchor window
defines how many older pivots can be used with a recent pivot to create a valid trendline.

min bars between anchors
defines the minimum distance between two trendline anchors. a low value creates shorter lines. a higher value creates more meaningful structural lines.

allowed pierces
defines how many times price is allowed to pierce a line during validation. zero means strict validation.

pierce tolerance atr
defines the atr-based tolerance used when checking if price has pierced a line. a lower value is stricter. a higher value allows more flexibility.

touch tolerance atr
defines the atr-based tolerance used to count touches on a trendline. a higher value detects more touches. a lower value keeps only precise touches.

dedupe distance atr
filters trendlines that are too close to each other. a higher value removes more duplicate lines.

max validation span
defines the maximum number of bars used when validating a trendline. this prevents the indicator from validating lines across an excessive historical distance.

---

channels, break and extension

show channels
enables channels around the dominant trendline. channels help visualize the reaction area around a trendline instead of focusing only on a single line.

break = n consecutive closes beyond
defines how many consecutive candle closes are required to confirm a break. a value of 1 is faster. a value of 2 or more is stricter.

forward projection bars
defines how far the trendlines are projected into the future.

infinite extension
extends the lines continuously to the right. this is useful when using trendlines as ongoing dynamic support and resistance.

---

display

price projection label
shows the projected price at the end of a trendline. this helps identify the current reaction level quickly.

show trendline labels
enables or disables labels on trendlines. keeping this off gives a cleaner chart.

strength rating
shows a visual strength rating based on the number of valid touches. more touches generally mean a more important line.

show dashboard
enables the dashboard. the dashboard summarizes confirmed support, confirmed resistance, htf support, htf resistance, htf extremes, and validation status.

dashboard position
selects the position of the dashboard on the chart.

---

aesthetics

support
sets the color of support trendlines.

resistance
sets the color of resistance trendlines.

htf glow / accent
sets the accent color used for higher timeframe emphasis.

broken
sets the color used when a trendline is broken.

atr length
defines the atr length used for tolerances, validation, touch detection, break detection, and duplicate filtering.

---

how to use the indicator

start by using confirmed degree and htf degree. these two modes give the cleanest structure.

live degree is useful for faster market reading, but beginners should understand that live pivots can repaint while they are forming.

support lines are usually below price and can act as dynamic reaction zones.

resistance lines are usually above price and can act as dynamic rejection zones.

when price approaches a confirmed or htf trendline, watch how it reacts. price can reject the line, break through it, or compress near it before a stronger move.

a break is cleaner when price closes beyond the line. this is why the break confirmation input is important.

---

beginner tutorial

1. choose your trading timeframe, such as 15m, 1h, 4h, or 1d.

2. enable confirmed degree to display stable trendlines.

3. enable htf degree to display higher timeframe structure.

4. keep live degree enabled only if you want more reactive lines.

5. wait for price to approach a support or resistance trendline.

6. observe the candle reaction near the line.

7. a rejection can indicate that the line is still respected.

8. a confirmed close beyond the line can indicate a structural break.

9. use the dashboard to monitor the main confirmed and htf levels.

10. never use a trendline alone as a full trade signal. combine it with market structure, volume, candles, liquidity, and risk management.

---

simple beginner setup

live degree: off
confirmed degree: on
htf degree: on
anchor source: wick
confirmed pivot l/r: 10
htf pivot l/r: 8
allowed pierces: 0
break = n consecutive closes beyond: 2
show channels: on
show trendline labels: off
show dashboard: on

this setup keeps the chart clean and focuses on confirmed structure.

---

scalping setup

live degree: on
confirmed degree: on
htf degree: on
live pivot l/r: 3 to 5
confirmed pivot l/r: 8 to 12
break = n consecutive closes beyond: 1 to 2
forward projection bars: 10 to 30
show trendline labels: off

this setup gives faster signals and more reactive structure, but it should be used with more caution.

---

swing trading setup

live degree: off
confirmed degree: on
htf degree: on
confirmed pivot l/r: 10 to 20
htf pivot l/r: 8 to 15
htf timeframe: 1d or 1w
htf compute in log space: on for crypto
break = n consecutive closes beyond: 2 or 3
infinite extension: on

this setup focuses on larger trendlines and reduces short-term noise.

---

dashboard guide

conf resist
shows the main confirmed resistance trendline level.

conf support
shows the main confirmed support trendline level.

htf resist
shows the main higher timeframe resistance trendline level.

htf support
shows the main higher timeframe support trendline level.

htf ath / atl
shows the higher timeframe extreme levels used for macro context.

validation
shows that the lines are built using structure and validation logic.

---

important notes

a trendline is not an automatic buy or sell signal.

a trendline is a decision zone.

the more clean touches a line has, the more important it becomes.

a close beyond a line is usually more important than a wick through the line.

higher timeframe lines should always be respected because they represent larger market structure.

this tool is designed to organize chart structure, but risk management remains essential.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.