alexgrover

TF Segmented Linear Regression

Fit a line at successive intervals, where the interval period is determined by a user-selected time frame, this allows the user to have an estimate of the intrinsic trend within various intervals.

Settings

  • Timeframe : Determine the period of the interval, if the timeframe is weekly then a new line will be fit at the start each weeks, by default "Daily"
  • Mult : Multiplication factor for the RMSE, determine the distance between the upper and lower extremities
  • Src : Input data for the indicator
  • Plot Extremities : Logical value, if true then the extremities of the channel are plotted, if false only the midline is plotted, true by default.

Usage

The timeframe setting should be higher than the current chart timeframe, note however that too large values of timeframe might return an error. Since the maximum number of lines that can be plotted is 54, using the extremities will only return 18 channels.

The indicator can be compared to the "regression trend" drawing tool


Main tf = 5 min with the indicator using a daily timeframe , the filled area is produced by the regression trend drawing tool using the same interval as the indicator, and coincide with it.


Main tf = 15 min with the indicator using a weekly timeframe , wider channel indicate that the values tend to be farther away from the fitted line.

A line with a significant slope indicates a strong trend, in that case, the width of the channel is determined by the amplitude of the retracements in the trend, with a narrower channel indicating a cleaner trend.

When the fitted line has a low slope value and the channel is wide, it means that there were two or more variations of opposite directions with large amplitudes within the interval, this also indicates that a linear model is not appropriate.

A slope approximately equal to 0 with a low channel width indicates a trendless market with cyclical variations of low amplitude in it.

Refrences

Determining the starting and ending points of the fitted line was done using a linear combination between the wma and sma


The wma and sma functions both use a series as period by making use of the Wma and Sum functions in the following script


Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
Patreon: https://www.patreon.com/alexgrover

Become a Patreon and get access to exclusive technical indicators!

You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts

Bình luận

This publication will be featured in our "Best Scripts of The Month" selection. Thank you for your valuable contribution to the TradingView community, and congrats!
+3 Phản hồi
Very brilliant works Alexgrover!

Now it can descriptive trend analysis way more convenience; Thank You so much for sharing this for us.
+2 Phản hồi
@ICEKI, I really like the "analytical" aspect of such script, I am glad you like it :D Thx for your support as always
Phản hồi
ICEKI alexgrover
@alexgrover, You're very welcome; I also the fans of analytical and forecast/prediction aspect too. Therefore I love all your work as others coders too =D

Keep it up Alexgrover! Appreciated your great works as always <3
+1 Phản hồi
I suggest that you tell the novice how to write the code according to the example. I will be the first one willing to pay for it. Your meticulous and patient explanation ability is absolutely competent.
+1 Phản hồi
alexgrover flush6789
@flush6789, I'll try to add more details on the code of future indicators, but it takes quite a lot of time.
Phản hồi
Very nice, keep up the good work!
+1 Phản hồi
alexgrover SwissPips
@SwissPips, I'll certainly try ^^ Thx a lot for your comment
Phản hồi
Hey Alex, this is amazing! very elegant code! would the way you are using the timeframe be usable for any multi-timeframe indicator?
+1 Phản hồi
Wow. Thanks again Alex!
+1 Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Cách thức hoạt động Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Xu Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất