TradingView
tbiktag
2021年10月13日午後5時13分

Repeated Median Regression with Interactive Range Selection 

Ether / United States DollarCoinbase

詳細

Greetings to all!
As you probably know, TradingView now supports interactive inputs that can be directly set on a chart. I decided to build a tool that takes advantage of this incredible feature. This tool applies robust linear regression within a time interval on the chart that you can select interactively.

Method
The script uses an algorithm known as Repeated Median Regression. It belongs to the class of so-called robust regression methods. The reason they are called “robust” is that these methods are much less sensitive to outliers in the data than the ordinary least squares.

The calculation procedure is as follows: For each data point, this algorithm collects the slopes of the lines connecting that point to all other points in the sample, calculates the median slope, and then obtains the median value of these median slopes. Subsequently, it calculates the intercepts of the regression line and the mean absolute error (MAE) of the model.

Based on these results, a linear channel is plotted. The upper and lower channel boundaries are set by the MAE value multiplied by a user-defined coefficient.

Further reading
You can read more about robust linear regression on Wikipedia.
For more information on interactive inputs, see the User Manual's page.

Previous publication
I have already posted a script using the repeated median regression method. Although the core algorithm is essentially the same, interactive input provides fundamentally different functionality to the current script.

A word of caution
Currently, the interactive interval selection mode can be triggered only when the script is loaded to the chart. Thus, you might have to reload it when switching between different timeframes.

リリースノート

The core algorithms are transferred to the public library. There are no changes in the functionality of the script.

リリースノート

An option has been added to mark the beginning and end of the selected interval on the chart ("Show Interval Borders").
コメント
Kkishore1
When I select the script it says " Set T1 Time" what does that mean and where I can set this?
tbiktag
@KkishoreSharma, You simply click at the point on the chart where you want to set the beginning of the analyzed time interval.

After that you will see the message "Set the T2 time". Now you can click again and select the end of the interval.

You can also move the interval boundaries.
Kkishore1
@tbiktag, Thank you, I got it. Appreciate your work.
casinca
Thanks again friend, i'm having fun drawing robust regressions a lot easier drag and drop now than previous version. Underrated tool imo it's like some kind of composite TPO
Tips for new people : always keep a linear too, sometimes you might be surprised of the result and might work better.
tbiktag
@casinca, Thanks a lot for the comment! I really appreciate it. I agree, the new interactive feature is just perfect for tools like this. But of course people still have to get used to it.
ES-View
Nice! Is it possible to add a log version or option?
RemarcAx
Thank you very much for this indicator! How do I set this up to make it work on the 5-10-15 min chart? Works fine on daily but shows error on the lower time frames. Thanks
serhito
Hi ! Great tool. Is there any way to just set the time range as the last 1Y or 2Y, so there is no need to adjust the dates as time progresses ?
Thanks
kakola
Great job!
akmaha
Hi, I just included this code to another script together for which I need not to be interactive. Since it prompts at the time of adding to the chart it throws error. This is the only reason.
詳細