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 Pro script.
As you know, is very subjective and many people (even professionals) draw different 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 scripts. In this, I use channel idea so it can check number of it contains, it checks H/L/C in the channels as well. it also checks the angle while choosing . then we get stronger and useful automatically.
There are some option in the script, let see one by one:
Pivot Period: The Length to calculate Highs/Lows
Source : Option to use "High/Low" or "Close" as the source for
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 , there must be an angle between them to choose best . you can set the angle with this option.
Minimum Strength: there can be many but we need to choose/use stronger ones. with this option you can set the number of a trend channel have to contains.
Maximum Loopback Length: by default the script can check 40 highs and 40 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 as: you can see as "Trendline", "Channel", "Trend Channel". you can see examples below.
Enable Weak Trend Lines: if there is no strong enough (as defined in "Minimum Strength" option) you have option to see a weak . 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 . the examples are below
Line Style: can be Solid or Dashed as you wish
Color theme: colors of the Up/Down can be set. 'Red', Lime, Blue, White, Black, Olive, Gray
you can see the as channels:
you can see Trend Channels to see the big picture.also there is dotted as weak defined above.
you can set color/width of 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.
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
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:
- 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"
- 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)
- 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.
- "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:
- "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
- Bottom Left
- Bottom Middle
- Top Left
- Top Middle
- "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
- Pre-Calculation step improved
- Main algorithm improved
- Label Positioning fixed
- 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:
- 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:
- 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:
- 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.
- 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
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.
- "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
- 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"
- 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
- 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!
تحذير: يرجى القراءة قبل طلب الوصول.