Trend Lines Pro

Hello Traders!

We need to make things better & better to solve the puzzle and I try to do my best on this way. now I am here with my new Trend Lines Pro script.

As you know, Trend Lines is very subjective and many people (even professionals) draw different Trend Lines on the same chart. This is confusing and there must be an automation to make the life easer. with this tool I tried to automate it.

The idea in this script is different from my previous trend lines scripts. In this, I use channel idea so it can check number of pivot points it contains, it checks H/L/C in the channels as well. it also checks the angle while choosing trend lines . then we get stronger and useful Trend Lines automatically.

There are some option in the script, let see one by one:

Pivot Period: The Length to calculate Pivot Highs/Lows

Source : Option to use "High/Low" or "Close" as the source for Pivot Points

Threshold Rate : This rate is used for channel width. it you give bigger numbers then you get bigger channels. it's 4 by default

Minimum Angle Rate for new Trendline: if there are different trend lines , there must be an angle between them to choose best trend lines . you can set the angle with this option.

Minimum Strength: there can be many trend lines but we need to choose/use stronger ones. with this option you can set the number of pivot points a trend channel have to contains.

Maximum Loopback Length: by default the script can check 40 pivot highs and 40 pivot lows but to make the script faster and useful I needed to add a limitation for the number of bars that the script can go back.

Show Trendlines as: you can see trend lines as "Trendline", "Channel", "Trend Channel". you can see examples below.

Enable Weak Trend Lines: if there is no trend lines strong enough (as defined in "Minimum Strength" option) you have option to see a weak trend line . that is useful sometimes. if you enable this option weak lines are shown as dotted lines.

Show Price Labels on Trendlines: the script can show the price levels to break trend lines . the examples are below

Line Style: trend lines can be Solid or Dashed as you wish

Color theme: colors of the Up/Down Trend lines can be set. 'Red', Lime, Blue, White, Black, Olive, Gray

you can see the Trend Lines as channels:

you can see Trend Channels to see the big picture.also there is dotted trend line as weak trend line defined above.

you can set color/width of trend lines as you wish.

the script is fast enough to run on 1sec chart:

you can use this script on any chart, fx pairs, stocks, indices etc

I made a short video to explain how to use it and some options:

Please PM for access.


DISCLAIMER: No sharing, copying, reselling, modifying, or any other forms of use are authorized for our documents, script / strategy, and the information published with them. This informational planning script / strategy is strictly for individual use and educational purposes only. This is not financial or investment advice. Investments are always made at your own risk and are based on your personal judgement. I am not responsible for any losses you may incur. Please invest wisely.
ملاحظات الأخبار: Changed product key part.
ملاحظات الأخبار: New Updates:
Update Improved algorithm to make it faster
Update Some functions was improved
Update Using Arrays in the script (Thanks to Pine Team for adding Arrays)
Update Pivot Points are shown as arrows instead of H/L letters
Update Color limitation is removed, so you can choose any color for trend lines
Update Default value for "Maximum Loopback Length" is now 350. you can set it as you wish.
Update Now you will get Closing price and broken support/resistance levels the Alerts. as an example,
example: you will have alerts like "Support Broken, Close: 10198.45 Support: 10202.27", where, Close = Closing price, Support: Broken S/R level
Update Following Alerts Removed: Because there are alerts when support/resistance levels broken and when Price in Support/Resistance
"Support Broken but still in channel"
"Resistance Broken but still in channel"
Fixed if the number of total candles was less than 300 then there were no trend lines. Fixed

ملاحظات الأخبار: New Updates:
Update: Alerts improved
Update: Added two new Alerts!
--------> "Price went up from Support Channel"
--------> "Price went down from Resistance Channel"
Price sometimes enters into Support/Resistance channel and it may break it or it may have reversal. when you got one of these new alerts, price may have reversal soon. I recommend you to use "Once Per Bar Close" option in the alerts. I also recommend you to use this option for Support/Resistance broken alerts.

lets see an example. here on the first chart, price closed in the resistance channel, now it may break the resistance or it may go down. on next candle Price closed below resistance channel, this may be a signal of price may go down but it's not guaranteed and we can not see the next candles. if you want to take short position after this alert, you should put your stoploss just above the resistance channel

on the next candles, after price could not break the resistance, it went down until it finds a support:
ملاحظات الأخبار: An issue with the arrays was fixed. New improvements and updates are on the way
ملاحظات الأخبار: Updates:
- The main algorithm and some functions improved
- A new option added "Show Last Broken Trend Line" now Last broken trend line can be shown on the chart up to 10 candles (you can set the length as you wish, by default it's 5). This option was added because we may need to see if it's a trap and the price will come back or if trend lines was really broken (after you get the alert Support/Resistance broken). in the following example the broken trend line and re-test move (blue and dotted by default) is shown:
- Alerts were improved, now you will get more info from the alerts. for example when the support/uptrend line was broken, you will get closing price, broken support level and the current support and resistance levels if they exist. in the following example: there are 2 uptrend and 1 down trend lines.
then on next candle uptrend line (support) broken. then you will get Alert like "Support broken, Close: 11589.09 support: 11624.84 Current Support: 11123.08, Current Resistance: 11880.78"
ملاحظات الأخبار: New Updates:
- Improvements in the main algorithm
- Lower band of Up Trend Channel and Upper band of Down Trend Channel were adjusted to pass on pivot points (some users requested)
- New Alerts added for Pivot High and Pivot Low (you should know that the Pivot Points are calculated by checking left/right candles. so what to with these alerts? for example if you get Pivot High alert in the up trend then you may think price is in a correction wave. but as Pivot Points are laggy you should not use them as buy/sell signals)
ملاحظات الأخبار: New Updates:
- Broken Trend Lines are shown according to trend line style now. it means that: if Trendlines are shown as "Channel" then lines are shown with threshold value, so does broken trend lines same. if Trendlines are shown as "Trendline" or "Trend Channel" then lines passes on pivot points, so does broken trend lines same. (Users request)
- Style option added for Last Broken Trend Lines: Dotted or Dashed. it's Dotted by default. (Users request)
- When you open a chart if there is broken trend lines on last 10 bars then the script can show them now, no need to replay (1min or higher time frames). you can set the number of bars using "Show it for ? Candles" option (by default it's 5). "Show Last Broken Trend Line" option should be enabled, also "UTC" value under it must be set same as the chart timezone. important: Enabling "Show Last Broken Trend Line" causes much more calculation, so I recommend you to enable it only when you needed to check broken trend lines. (Users request)
- Important: because of thr script can not know chart timezone, new UTC option added under "Show Last Broken Trend Line" option, this value is only used to calculate last N bar to show last broken trend lines. it should be same as chart timezone. You can see/change the chart timezone and/or time at the bottom bar by clicking on the clock or in the chart settings in the Symbol tab. for example: "New York UTC -4", "London UTC +1", "Berlin UTC +2", "Moscow UTC +3", "Beijing UTC +8" etc. If you have any question please contact me.
- Minimum value for Pivot Period can be set to 1 now. (it was 2). (Users request) I recommend you to use default values (it's 4 by default) and zoom the chart using lower time frames.
ملاحظات الأخبار: New Updates:
- "Show Angle Info" option added. at the moment we can not get angle info in Pine but in this new version the script can calculate/show the angle of the Trend Lines!!
- "Change Color if Angle >=" option added. With this option, color of the trend lines changes in real time (if it has an equal or greater angle than user-defined value). default value is 45°
- The script can now show "Last Broken Trend Lines" if they exist in last 20 candles (max value was 10). showing last broken trend lines needs much more calculation, so I recommend you to enable it only when you needed to check broken trend lines.
- With this new version you can set different colors for weak and strong trend lines. in the options you can see Strong Up/Downtrend Color and Weak Up/Downtrend Color and set as you wish. by default they are same colors.
- Two New Alerts Added: with this new version. if you don't want to get alert on each candle, you should set following alerts using "Only Once" option
----->"Up Trendline with Angle Greater than" (45° by default)
----->"Down Trendline with Angle Greater than" (45° by default)
- There was an issue if there is huge wicks in the chart, it's fixed in new version (huge wicks generally may appear in newly created cryptos). as it's weird candles, the angles may not be accurate in these types of charts.
- An issue with the arrays was fixed.
- A few improvements in the main algorithm.

Example for Angle Info:

Example: if the angle of trend line is higher than user-defined value:

Example for last broken trend line:
ملاحظات الأخبار: Improved the script by using array of Lines and array of Labels instead of individual variables.
ملاحظات الأخبار: New Updates:
- "Market Structure" option is added. it checks Market Structure for 50, 100, 150 and 200 bars and shows them in a panel at top-left or bottom-left of the chart. (explained below)
- Pre-calculation step added, so the main algorithm works much faster now.
- "Show it for ? Candles" option under "Show Last Broken Trend Line" changed as "Number of Bars to Check". because it was a bit confusing for some users.

New Market Structure option:
The script calculates Market structure for 50, 100, 150 and 200 bars. Market Structure is calculated using angle of Linear Regression slope for each length.
Market Structure types:
- Uptrend or Strong Uptrend
- Downtrend or Strong Downtrend
- Sideways (or Choppy)

The colors of the bars:
- Lime : Uptrend
- Green : Sideways (slightly up)
- Red : Downtrend
- Olive : Sideways (slightly down)

Meaning of the Signs:
>> : Momentum of the Trend Increased
>> : Momentum of the Trend Decreased
== : No change in Trend Momentum

For example: if there is down trend and if you see ">>" sign then this means momentum of the downtrend is increasing. Another example: if there is up trend and if you see ">>" sign then this means momentum of the Uptrend is increasing. if you have question about it please send me private message

Explanation on the chart for Market Structure:

You have option to show Market Structure Panel at top-left or bottom-left of the chart. example for panel shown top-loeft of the chart
ملاحظات الأخبار: New locations added for Market Structure Panel. Also smaller text size used.
Available Locations:
- Bottom Left
- Bottom Middle
- Top Left
- Top Middle
ملاحظات الأخبار: fixed the published screen (removed unnecessary indicators from the chart)
ملاحظات الأخبار: New Updates:
- "Trend Channel With Midline" option added to the list under "Show Trendlines as". Also added coloring options for Middle Uptrend/Downtrend lines. (you can find screenshot below)
- "Show % Distance to Trendlines" option added. now you can see the distance between Closing price and eachTrend Lines. The distance is shown as percentage of closing price. enabled by default. (explained below)
- Now Trend Lines Pro can give external signals as input for your scripts. (you can find details below)
- Appearance of Market Structure is fixed.
- "Give Alert for Distance between Trendlines" option added. if you are trading using triangles then you can get alert if the distance between trend lines gets equal/lower than a percentage of closing price. by default it's 2% of closing price. you can set it using "Max Distance for Alert" option. I recommend using "Once Per Bar" alert option while setting alert. you must enable this option to get alert. (you can find related screenshot below)

An example screenshot for Trend Channel With Midline. Better if there are 2 or less trend lines.

if you enable "Show % Distance to Trendlines" option you can see the distance between Closing Price and Trend lines. in following example if the price goes up 4.48% then it can reach downtrend line, and if the price goes down 3.65% then it can reach uptrend line.

if you have script and want to get signal from Trend Lines Pro you can get following signals. you need to get external_signal as input in your script

if you are trading using triangles then you can get alert if the distance between trend lines gets equal/lower than a percentage of closing price. by default it's 2% of closing price. you can set it using "Max Distance for Alert" option. I recommend using "Once Per Bar" alert option while setting alert
ملاحظات الأخبار: New Updates:
- Pre-Calculation step improved
- Main algorithm improved
- Label Positioning fixed
ملاحظات الأخبار: New Updates:
- Pre-calculation step improved
- Angle Bisector feature added. Explained below. New options for Angle Bisection:
==> Show Angle Bisector. to see Bisector line you need to enable this option, not enabled by default
==> Bisector Line Color. you can set Bisector Line Color
==> Bisector Line Style. you can set Bisector Line Style

Angle Bisector is show as a line that splits an angle between nearest two trend lines into two equal angles. you can see how it's shown in the following screenshot:
ملاحظات الأخبار: New Updates:
- Improvements in the main algorithm
- "Don't Show Trendlines If The Angle is" option added. if you enable this option and if you set the angles in the following options then it won't show the trend lines which has less/greater angles than:
==> "Less Than"
==> "Greater Than"

- New options added for Price Labels of Up/Down trendlines. now you can change:
==> Label size (Tiny, Small, Normal, Large)
==> Label color / Transparency (you can choose any color)
==> Text Color / Transparency (you can choose any color)
- "Don't need zoom-in zoom-out" / "Start Point Greater Than (292)" options added.If start point of a trend line is in unvisible area then TV doesn't show it until you zoom-out/zoom-in. visible area means that when you reset the chart, 292 bars are visible on the screen but bar 293 and previous bars are in unvisible part. so I added this option and it's enabled by default. if starting point of any trend line is in unvisible area (bar 293 or previous) then the script finds two new points on the line in visible area, draws the line and extend it left and right. This option will be removed when TV fixed it. if you need further explanation send me message please ;)

An example for price labels:
ملاحظات الأخبار: New Updates:
- Fix: The angles for the Trend Lines are calculated in the script. if there is not enough candles on the chart to calculate (less than 292 candles) then the angles will not be shown.
- Update number and Release Date added => "TLPu16.130221". now you can see if you have updated version or not
==> TLP : Trend Lines Pro
==> u16 : Update 16
==> 130221 : 13.02.2021 (update date)

Here is the screenshot to show where you will see it:
ملاحظات الأخبار: New Updates (TLPu17):
- With this update, now there is Grouping in the Indicator menu. Options are well organized and more readable.
- Added an option for the width of broken trend lines
- Under "Show Last Broken Trend Line" option Maximum value for "Number of Bars to Check" increased to 50 (it was 20). with this update you can see broken trend lines if there is one in last 50 candles. I recommend you to enable this option only when you need to check broken trend lines. because it uses a lot of processor time
- 4 new Alert added:
==> "Support/Resistance Broken" (if you set it then you get alert when support or resistance broken)
==> "Move From Resistance/Support" (if you set it then you get alert if the price went away from Support or Resistance)
==> "Price in Support/Resistance Channel" (if you set it then you get alert when price is in Support or Resistance channel)
==> "Strong Up/Down Trend" (if you set it then you get alert when there is Strong Uptrend or Downtrend) (strong Up/Down trend means if the angle of the trend lines is greater than 45)
- The External Signal will give you the precentage distance to closer Support or Resistance level as well. so if the External signal is less than 1 then it's distance info. if the Resistance is closer than the Support then it will be positive decimal number, if the Support is closer than the Resistance then it will be negative decimal number. (% distance). below you can see in the example. There is downtrend line and also uptrend line. as you can see Support/Uptrend line is closer to current Price, so it will give the % distance to Support level. if you use external signals from TLP in your scripts and have any question send me a private message please.
ملاحظات الأخبار: Options menu headers fixed. (some lines was breaking off into two lines in some browsers)
ملاحظات الأخبار: New Updates (TLPu18):
- All in One Alert option added. With this update you need create only 1 alert to get all alerts for a symbol/security. You don't need to add alert for each condition anymore. You can find explanation and screenshots below.

Under the new "ALERTS" header in the options you can see the conditions and frequency (for each condition) to set alerts. Frequency can be "Once Per Bar" or "Once Per Bar Close".
Conditions that you can enable/disable to get alerts (Support refers to Uptrend line and Resistance refers to Downtrend line)
- Support/Resistance Broken (you can get alert when Support Broken or Resistance Broken)
- Price in Support/Resistance Channel (you can get alert when Price is in Support Channel or Resistance Channel)
- Price went up/down from S/R (you can get alert when Price went up from Support channel or when Price went down from Resistance channel)
- TrendLine with Big Angle (you can get alert if the angle of trendline is greater than 45 by default)
- Distance between Trendlines (triangle traders prefer this, you can get alert when the distance between downtrend and uptrend lines is less than 2% by default)

So how will you create this alert?
At the first step you need to enable/disable the Conditions and set Frequency for each one as seen in the following screenshot:

At the second step you need to create only 1 alert as seen on the following screenshot
- in the Condition menu choose "TLPu18" and "Any alert() function call"
- type a name in "Alert name" box like "TLP All Alerts" or any other name you want

Frequency explanation:
Once Per Bar: Has the alert trigger every time its condition is met, but not more than 1 time for each price bar.
Once Per Bar Close: Makes the alert trigger every time its condition is met at the bar's close. so you get the alert at the beginning of next candle.
ملاحظات الأخبار: New Updates (TLPu19):
- "Don't show Trendline if the Distance is Greater than" option is added. if enabled then the trend lines are not shown if the distance between the trendline and closing price is greater than the value you set (Default value %20). if there is any other possible trend lines which has smaller distance then they are shown.
- "Price went Up from Support channel" and "Price went Down from Resistance channel" alerts improved. it was checking if the last closing was in the channel, now it checks if last or current High/low was in Resistance/Support channel. so now, if the price touches the channel and closes out of the channel you will get alert.
Note: In the last release I wrote in the explanation to enter an alert name while using "All alert() function call", but if we give a name for the alert we are not able to see related alert in the Alert message box. so while using "All alert() function call" please do not enter a name for the Alert, leave the Alert name empty
ملاحظات الأخبار: New Updates (TLPu20):
- Angle info added to following alerts. you will get angle info in the alert messages. for example if downtrend line was broken then you will see the angle of broken downtrend line in the alert message. (users request)
-- Support / Resistance Broken Alerts
-- Price went up/down from Support / Resistance Channel Alerts
-- Price in Support / Resistance Channel Alerts

Example: alert message for Support Broken signal: "Support Broken, Close:33412.27 Support:33.543.33 Angle:27° Current Support:32685.55 Current Resistance:36701.1"
ملاحظات الأخبار: New Updates (TLPu21):
- Added the option "Check Bouncing using". with this option you can choose the source for "Price Went Up/Down from Support/Resistance Channels" Alerts. options: "Wicks" or "Open/Close"
- in Alerts part, added "Alert Types to Trigger" option added. you can choose "All Alerts", "Only Longs", "Only Shorts".
-- these alert type is used for following alerts:
--- Support Broken (Short)
--- Resistance Broken (Long)
--- Price went up from Support Channel (Long)
--- Price went down from Resistance Channel (Short)
- Symbol info and Timeframe info added to the alerts, you will get alert messages like "BINANCE:BTCUSDT, 1h, Resistance Broken..."
- Following new Alerts added
-- Support Re-Broken
-- Resistance Re-Broken
What is Support/Resistance Re-broken? anytime if down/up trend line is broken but then price change direction and went through related broken trend line then you can get this alert. to get these alerts you need to set "Number of Bars to Check" because you can get alert if broken trend line is visible on the chart
here is an example for "Support Re-Broken": down trend line got broken but later the Price comes back to Broken Trend line
ملاحظات الأخبار: Minor update:
- new signals added to "External Signal" . new signals:
-- Support Re-broken => 9
-- Resistance Re-broken => 10

- Long/Short words added to following alerts
-- Support/Resistance Broken
-- Price went Up/Down from Support/Resistance Channel
نص برمجي للمستخدمين المدعوين فقط

الوصول إلى هذا النص مقيد للمستخدمين المصرح لهم من قبل المؤلف وعادة ما يكون الدفع مطلوباً. يمكنك إضافته إلى مفضلاتك، لكن لن تتمكن من استخدامه إلا بعد طلب الإذن والحصول عليه من مؤلفه. تواصل مع LonesomeTheBlue للحصول على مزيد من المعلومات، أو اتبع إرشادات المؤلف أدناه.

لا تقترح TradingView الدفع مقابل النصوص البرمجية واستخدامها حتى تثق بنسبة 100٪ في مؤلفها وتفهم كيفية عملها. في كثير من الحالات، يمكنك العثور على بديل جيد مفتوح المصدر مجانًا في المكتبة العامة.

تعليمات المؤلف

If you want access then please send me message with your request. Thank you!

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

تحذير: يرجى القراءة قبل طلب الوصول.


Wonderful!!! Can you give access ? Thanks
100 ‎عملة افتراضية
+111 رد
is it possible to gain access :=)
200 ‎عملة افتراضية
+41 رد
Bu komutu bana da açar mısınız.
100 ‎عملة افتراضية
+27 رد
Perfecttt, Can you give access? Thanksssss
100 ‎عملة افتراضية
+16 رد
ACFortes sinansoydan2012
@sinansoydan2012, sorry, commnent in the wrong field
It work well and it's very useful in trading can you please please give me access
100 ‎عملة افتراضية
+16 رد
HI, Can you please provide access?
100 ‎عملة افتراضية
+13 رد
Congratulations for your job!!! May I have access?
Tanks in advance
500 ‎عملة افتراضية
+11 رد
Can you give access?
500 ‎عملة افتراضية
+7 رد
Looks great. Please give me the access. Thanks
200 ‎عملة افتراضية
+7 رد