vnhilton

Visible Range Linear Regression Channel [vnhilton]

(OVERVIEW)
This indicator calculates the linear regression channel for the visible bars shown on the chart instead of the traditional fixed length linear regression channel TradingView provides (and is more accurate I believe). Inspired by TradingView's Linear Regression Channel and Visible Average Price indicator, and the DAS Trader linear regression indicator.

(FEATURES)
- Ability to extend lines to the right
- Show/hide individual lines
- Adjust standard deviation of bands
- Adjust line style and width of basis and band lines
- Change individual line colours and plot fills between the lines

(DIFFERENCES)
If you compare this indicator to TradingView's Linear Regression Channel, you will notice some differences (as of 11th June, 2023). Differences and reasons are:

1) The intercept is wrong. The formula TradingView uses to calculate the intercept includes the addition of the gradient, which I believe is incorrect. Difference #2 is also why the intercept is wrong. This indicator omits that addition. This was verified by comparing the gradient calculated in this indicator with the gradient determined by Excel with the same data.

2) The gradient is "wrong". In quotations as essentially TradingView's code attempts to find the line of best fit, with the y-axis on the most recent bar instead of the oldest bar. This leads to the gradient being the opposite to the gradient found in this indicator, which isn't wrong, but the later formula used to calculate the intercept doesn't take this into account, resulting in an incorrect intercept value. The gradient and intercept values in this indicator matches those found in Excel.

3) Standard deviation bands of both indicators. I believe the code TradingView uses to calculate standard deviation is incorrect (basing this just through visuals). This indicator uses the array.stdev function to find the correct value (verified with Excel numbers).
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?