TradingView
QuantVue
9 Jun 2023 pukul 22.09

Trendline Pivots [QuantVue] 

US Tech 100 IndexPepperstone

Deskripsi

Trendline Pivots

The Trend Line Pivot Indicator works by automatically drawing and recognizing downward trendlines originating from and connecting pivot highs or upward trendlines originating from and connecting pivot lows.

These trendlines serve as reference points of potential resistance and support within the market.

Once identified, the trend line will continue to be drawn and progress with price until one of two conditions is met: either the price closes(default setting) above or below the trend line, or the line reaches a user-defined maximum length.

If the price closes(default setting) above a down trend line or below an up trend line, an "x" is displayed, indicating the resistance or support has been broken. At the same time, the trend line transforms into a dashed format, enabling clear differentiation from active non-breached trend lines.

This indicator is fully customizable from line colors, pivot length, the number lines you wish to see on your chart and works on any time frame and any market.

Don't hesitate to reach out with any questions or concerns.

We hope you enjoy!

Cheers.

Catatan Rilis

Added the ability to configure alerts on the trendline pivots.

Catatan Rilis

Added QuantVue to indicator title

Catatan Rilis

Added team name to script.

Catatan Rilis

Added the option to toggle Log or Regular scale.
Komentar
clickclang
@tradeleblebi This is amazing, is it possible to add alert on those crosses?
QuantVue
@clickclang, yep! We’ll be adding that in
QuantVue
clickclang
@QuantVue, thank you :) appreciated
janor123
@QuantVue Great start! However, I've identified (and possibly solved) a bug. The issue is with the trendlines not connecting properly when the chart is set to Log scale, due to the way the trendline is calculated. In a linear scale, the difference between two points is the same regardless of the value of the points. However, in a logarithmic scale, the difference between two points depends on the value of the points.

In the provided code, the trendline is calculated using the formula y = mx + c, where m is the slope of the line and c is the y-intercept. This formula assumes a linear scale.

To adjust for a logarithmic scale, we need to calculate the slope and y-intercept differently. The formula for a line in a logarithmic scale is y = m * log(x) + c.

Therefore, the getSlope function needs to be adjusted to calculate the slope and y-intercept for a logarithmic scale. Here's how you can modify it:

getSlope(line)=>
slopePh = (math.log(line.get_y2(line)) - math.log(line.get_y1(line)))/(line.get_x2(line) -line.get_x1(line))
extendedPh = math.exp(ta.log(line.get_y2(line)) - slopePh * (line.get_x2(line) - bar_index))
extendedPh

This should adjust the trendlines to properly connect the start and end points when the chart is set to Log scale.
QuantVue
@janor123, we've just added code to be able to toggle which scale; log or regular! We appreciate the feedback.
aggarwalg04
Please add support and resistance and add more option 🙏
QuantVue
@aggarwalg04, We have a support & resistance indicator right here: tradingview.com/script/TzQgAQo4-Sup-Res-Levels-QuantVue/
basictradingtv
great!
QuantVue
@basictradingtv, thank you my friend
Lebih lanjut