OPEN-SOURCE SCRIPT
Auto Trendlines [ITA]

🟠 OVERVIEW
Auto Trendlines draws the current rising and falling trendlines from confirmed swing points, and counts how many times price has actually come back to each one.
A line through two points is not a trendline, it is a line. Every automatic trendline tool draws one the moment two pivots exist, and a lot of what ends up on the chart is exactly that - a line connecting two arbitrary highs that price has never once returned to.
What separates the two is how many times price came back to the line and turned away from it. A line with five touches is being respected by the market. A line with none is a drawing. So the count sits on the line itself rather than being left for you to work out by eye.
🟠 CONCEPTS
* Swing Point - A high or low with a set number of bars either side that did not exceed it. The line is built from confirmed swings only, so it does not move once drawn.
* Touch - Price reaching the line, not closing through it. Measured in ATR so the same setting behaves the same way on a five dollar stock and a seven hundred dollar index.
* Touch Spacing - A minimum number of bars between touches, so that one slow approach sitting on the line for several bars is counted once rather than several times.
* Break - A close beyond the line by more than the touch tolerance. The line stops extending, turns grey, and stays on the chart with the touch count it finished on, so you can see how respected it was before it gave way.
🟠 FEATURES
🔹 Rising and falling lines built from confirmed swing points, each with its own colour
🔹 A touch count carried on the line, so a respected line and an untested one are told apart at a glance rather than by memory
🔹 Optional fading of lines under a chosen touch count, which pushes untested lines into the background and leaves the tested ones standing out
🔹 Touch tolerance measured in ATR rather than points, so one setting works across symbols and timeframes
🔹 A minimum bar spacing between touches, so a single approach is not counted several times over
🔹 Breaks marked at the bar where the close crossed, with separate alerts for each direction
🔹 Broken lines stay on the chart, greyed, with their final count. A line that held five touches and then broke is worth seeing, and it can be switched off for only the two live lines
🔹 A line price has simply walked away from, without ever breaking it, is retired rather than drawn across years of chart
🟠 HOW TO USE
Swing Lookback is the setting that decides everything else. Raise it for fewer, larger and more significant lines. Lower it for more lines that react faster and mean less.
Read the touch count before you read the line. Two touches is the minimum any line has by construction, since it is drawn through two swings. It is the third and fourth that tell you the market is paying attention to it.
Set Fade Lines Under to 3 and the chart sorts itself. Lines nobody has tested recede, and the ones price keeps returning to are the ones you see.
Touch Tolerance controls how forgiving the count is. Too low and clean touches are missed because price turned a fraction early. Too high and everything nearby counts. Half an ATR is a reasonable starting point.
A break ends the line rather than flipping it. What price does after breaking a trendline it respected four times is a different question from what it does after breaking one it never touched, and the count is still on screen when it happens.
🟠 CONCLUSION
Drawing a line between two pivots is the part every tool does. Whether that line has ever mattered is a different question, and it is answerable with a number rather than an opinion.
Auto Trendlines draws the current rising and falling trendlines from confirmed swing points, and counts how many times price has actually come back to each one.
A line through two points is not a trendline, it is a line. Every automatic trendline tool draws one the moment two pivots exist, and a lot of what ends up on the chart is exactly that - a line connecting two arbitrary highs that price has never once returned to.
What separates the two is how many times price came back to the line and turned away from it. A line with five touches is being respected by the market. A line with none is a drawing. So the count sits on the line itself rather than being left for you to work out by eye.
🟠 CONCEPTS
* Swing Point - A high or low with a set number of bars either side that did not exceed it. The line is built from confirmed swings only, so it does not move once drawn.
* Touch - Price reaching the line, not closing through it. Measured in ATR so the same setting behaves the same way on a five dollar stock and a seven hundred dollar index.
* Touch Spacing - A minimum number of bars between touches, so that one slow approach sitting on the line for several bars is counted once rather than several times.
* Break - A close beyond the line by more than the touch tolerance. The line stops extending, turns grey, and stays on the chart with the touch count it finished on, so you can see how respected it was before it gave way.
🟠 FEATURES
🔹 Rising and falling lines built from confirmed swing points, each with its own colour
🔹 A touch count carried on the line, so a respected line and an untested one are told apart at a glance rather than by memory
🔹 Optional fading of lines under a chosen touch count, which pushes untested lines into the background and leaves the tested ones standing out
🔹 Touch tolerance measured in ATR rather than points, so one setting works across symbols and timeframes
🔹 A minimum bar spacing between touches, so a single approach is not counted several times over
🔹 Breaks marked at the bar where the close crossed, with separate alerts for each direction
🔹 Broken lines stay on the chart, greyed, with their final count. A line that held five touches and then broke is worth seeing, and it can be switched off for only the two live lines
🔹 A line price has simply walked away from, without ever breaking it, is retired rather than drawn across years of chart
🟠 HOW TO USE
Swing Lookback is the setting that decides everything else. Raise it for fewer, larger and more significant lines. Lower it for more lines that react faster and mean less.
Read the touch count before you read the line. Two touches is the minimum any line has by construction, since it is drawn through two swings. It is the third and fourth that tell you the market is paying attention to it.
Set Fade Lines Under to 3 and the chart sorts itself. Lines nobody has tested recede, and the ones price keeps returning to are the ones you see.
Touch Tolerance controls how forgiving the count is. Too low and clean touches are missed because price turned a fraction early. Too high and everything nearby counts. Half an ATR is a reasonable starting point.
A break ends the line rather than flipping it. What price does after breaking a trendline it respected four times is a different question from what it does after breaking one it never touched, and the count is still on screen when it happens.
🟠 CONCLUSION
Drawing a line between two pivots is the part every tool does. Whether that line has ever mattered is a different question, and it is answerable with a number rather than an opinion.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Pine Script developer & trader. I build clean indicators - Smart Money Concepts, scanners, risk tools. ITAtradingtools.com
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Pine Script developer & trader. I build clean indicators - Smart Money Concepts, scanners, risk tools. ITAtradingtools.com
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。