TradingView
LuxAlgo
17 ott 2023 14:35

Trend Lines [LuxAlgo] 

Bitcoin / United States DollarCoinbase

Descrizione

â‹…
Our new "Trend Lines" indicator detects and highlights relevant trendlines on the user chart while keeping it free of as much clutter as possible.

The indicator is thought for real-time usage and includes several filters as well as the ability to estimate trendline angles.

🔶 USAGE



Trendlines can act as support/resistance, with a higher number of tests indicating a more significant support/resistance role.



A broken TrendLine can be indicative of a potential trend reversal. The script highlights breaks with a label.

Users can additionally filter trendlines, only showing trendlines whose angles fall within a user set range:





This allows for the removal of potential clutter from the chart but also helps keep steeper or more horizontal trendlines.

🔶 DETAILS

When a swing (pivot point) is found, a Trendline is drawn when certain conditions are fulfilled.

An essential condition is that a Bearish Trendline (red) always occurs on a lower high, while a Bullish Trendline (blue) occurs on a higher low.



Our implementation will first show an initial dotted-styled TrendLine on confirmation, after which a solid-styled secondary TrendLine will develop. The latter will be used for the real-time detection of breaks at that line:

Furthermore, the script allows you to add more conditions:

🔹 Length (Swings)

A swing develops when a high/low is the highest/lowest against x highs/lows on the left AND right of that bar. x can be set by "Length" in settings.

The following images clarify this. The script confirms a swing where the yellow flag is shown; the high (here visualized with a purple label) is the highest point against x bars left and right of that point.
At that moment, this swing is checked against the previous swing. If all conditions are fulfilled, an initial TrendLine is drawn on confirmation.





After that point, a secondary thicker solid line is seen which keeps progressing bar after bar, until:

• a new TrendLine is formed
• the TrendLine is broken



🔹 Breaks between Swings

Once there is confirmation that a TrendLine can be drawn, the script allows you to filter for breakthroughs on that line. This can be set with "Check breaks between"

  • Disabled: the initial TrendLine is allowed to be pierced:
  • Check breaks between point A - point B: no breaks are allowed between both Swing points:
  • Point A - Current bar: no breaks are allowed between the first Swing point and the point of confirmation ('current' bar):


🔹 TrendLine breaks

As mentioned, the secondary TrendLine (solid line) progresses bar after bar until a new TrendLine is formed or the TrendLine is broken. When a TrendLine is broken, the TrendLine stops progressing, but if there isn't a new TrendLine and price return back, the TrendLine will re-appear, potentially giving several signals when the TrendLine is broken again.

Minimal bars allow you to regulate the amount of signals when the TrendLine is broken.

-> The secondary TrendLine must be uninterrupted for at least x bars before a potential break can be considered.

The following example shows 1 signal against 3 by adjusting this setting from 2 to 5:



🔹 Angles

Angles should normally be calculated when the units of the X and Y axis are the same. However, on our charts, the unit of the X-axis is bar_index (bars), and on the Y-axis the unit is price (¥, €, £, $,...).

It is not easy to normalize and create reasonably valid angles. Often certain angle calculations can differ through price changes or volatility.

Our calculate_slope() function tries to make corresponding angles through all bars.

We do this by calculating the difference between the highest/lowest price values in a certain bar range. The bar range is our X-axis, and the price difference is our Y-axis.

Zooming in/out will not change the amount of bars or the price. Since it does change our view on the chart, and thereby how we see the angles, we have included a setting where you can personalize the ratio between X and Y-axis (Angles -> Ratio X-Y axis).



Settings: Angles - Ratio X-Y axis:



🔶 SETTINGS

🔹 Swings

  • Length: Lookback period for the detection of swing points.


🔹 Trendline validation

Check breaks between:
  • Disabled: the initial TrendLine is allowed to be pierced
  • Check breaks between point A - point B: no breaks are allowed between both Swing points
  • Point A - Current bar: no breaks are allowed between the first Swing point and the point of confirmation ('current' bar)

Source (breaks): Source which invalidates TrendLine, default: close

🔹 TrendLine breaks

Minimal bars: The secondary TrendLine must be uninterrupted for at least x bars before a potential break can be considered.

🔹 Angles

Show: Toggle labels.

Ratio X-Y axis: Every user has his preferences regarding zoom, chart layout,...
If the shown angles are not according to your expectations, you can adjust this number.

Only TrendLine between: Only allow TrendLines between the minimum and maximum degrees. Set only the minimal and maximum values above 0.
Commenti
Tkysl
â‹…
Thank you for your effort, but I have an important suggestion for you, as someone who trades with trend lines, can you please add the "Minimum number of touches/retests to draw a trend line" feature to this script, because most of the trend lines drawn through between pivots or 2 touches are invalid. Thanks !
SyedFH
â‹…
@Tkysl, Excellent point. That's the first thing that came to my mind as well. Adding a number of touches is key. Please keep the minimum touches to 3 by default.
Tkysl
â‹…
@SyedFH, As he mentioned :) "Trendlines can act as support/resistance, with a higher number of tests indicating a more significant support/resistance role"
inter_good
â‹…
best trendline script! very nice and clean! i found that the angle between 7 to 16 is good for me. they act as good breakout trendline. other angled trendlines can be replaced with other methods such as moving averages and so forth. anyways, lux algo always makes alot of great scripts!
Cengizadabag
â‹…
Hello, first of all, I would like to thank you for this excellent work. However, I have a small piece of advice and a request. I'm sure it would be very beneficial for many people. This desire, at least for me and my friends, would make us very happy if you could add this feature. We want the "ANY ALARM" feature.
swttng
â‹…
Great indicator. I’ve tested many of them and this one is one of the best. Thank you! If I could make one request…could you add a thickness option to the ‘LINES’ checkbox? I find it’s a bit faint so hard to see. Thanks again!
abdoooo0
â‹…
Good job but fix it sometimes the trend is not drawn very well its glitching
eylna46446
â‹…
Very good
Pratik_4Clover
â‹…
Thanks!
Vibranium_Capital
â‹…
Ok now we are talking lol, I will see if this is better than Wolfe de dark trendline one .. sheesh
Altro