Linear Regression Slope - Version 2

16215 lượt xem
Version 2 - Linear Regression Slope. This version will have more freedom on picking your own length for all the Inputs.

One of the main reason I changed it is because, Slope calculation on transition period was not being computed properly. Because the Version 1, looks back the length assigned, and compute the slope based on two candle readings, could be 10 days apart or 50. That was misleading.

Therefore, I changed it to plot daily slope and Smooth it with an EMA .

Linear Regression Curve -
List of All my Indicators - https://www.tradingview.com/p/stocks/?so...
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
// Created by UCSgears -- Version 2
// Simple linear regression slope - Good way see if the trend is accelarating or decelarating

study(title="UCSGEARS - Linear Regression Slope", shorttitle="UCS-LRS", overlay=false)

src = close
clen = input (defval = 50, minval = 1, title = "Curve Length")
slen = input(defval=5, minval=1, title="Slope Length")
glen = input(defval=13, minval=1, title="Signal Length")

//Linear Regression Curve
lrc = linreg(src, clen, 0)
//Linear Regression Slope
lrs = (lrc-lrc[1])/1
//Smooth Linear Regression Slope
slrs = ema(lrs, slen)
//Signal Linear Regression Slope
alrs = sma(slrs, glen)
//loalrs = sma(slrs, (glen*5))

uacce = lrs > alrs and lrs > 0 
dacce = lrs < alrs and lrs < 0 

scolor = uacce ? green : dacce ? red : blue

plot(0, title = "Zero Line", color = gray)
plot(slrs, color = scolor, title = "Linear Regression Slope", style = histogram, linewidth = 4)
plot(alrs, color = gray, title = "Average Slope")

Bình luận

how i can add it to my strategy to trade when histogram turns green? Does the color in the histogram represents some value of the regression slope?
+2 Phản hồi
In a nutshell, its the slope of the slope. Take the condition for the color and work with it to add the strategy. If you need help, I can do it over the weekend.
Phản hồi
Thank you very much for code

Please help me out of code for slope value is above zero and green colour(Buy conditon) or slope value is below zero and red colour (Sell condition)
Phản hồi
Is there repaint?
Phản hồi
ucsgears ratgangofficial3
@ratgangofficial3, Not on this version
Phản hồi
@ucsgears, Awesome. This helps a lot more than you think aha.
Phản hồi
Thanks for the update. Hope to look more into this, this weekend
Phản hồi
version 1 was already awesome, I'm looking forward to test out your version 2
Phản hồi
ucsgears moveon
The Major glitch on version 1 was Slope was calculated from today and 5 days earlier (with default Setting), During transition period, the dips on curve was ignored, because of the look back was 5 days ago. This should be better.
Phản hồi
moveon ucsgears
What is the most important component to optimize the signal quality? Changing the "curve length" or the "slope length" or the "signal length" ?
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