TradingView
LuxAlgo
Aug 1, 2022 1:37 PM

TF Segmented Polynomial Regression [LuxAlgo] 

Bitcoin / United States DollarCoinbase

描述

This indicator displays polynomial regression channels fitted using data within a user selected time interval.

The model is fitted using the same method described in our previous script:

tradingview.com/script/zAkeVs4R-Polynomial-Regression-Extrapolation-LUX/

Settings

  • Degree: Degree of the fitted polynomial
  • Width: Multiplicative factor of the model RMSE. Controls the width of the polynomial regression's channels
  • Timeframe: Fits the polynomial regression using data within the selected timeframe interval
  • Show fit for new bars: If selected, will fit the regression model for newly generated bars, else the previous fitted value is displayed.
  • Src: Input source


Usage

Segmented (or piecewise) models yield multiple fits by first partitioning the data into multiple intervals from specific partitioning conditions. In this script this partitioning condition is for a user selected timeframe to change.

Segmented models can be particularly pertinent for market prices, which often describes a series of local trends.

Segmented polynomial regressions can describe the nature of underlying trends in the price from their fit, such as if an underlying trend is more linear (trending) or constant (ranging), and if a trend is monotonic.



The above chart shows a monthly partitioning on SPX 15m, using a polynomial regression of degree 3. Channel extremities allows highlighting local tops/bottoms.

For real time applications users can choose to fit a current model to incoming price data using the Show fit for new bars settings.

Details

The script does not make use of
line.new
to display the segmented linear regressions, which allows showing a higher number of historical fits. Each channel extremity as well as the model fit is displayed from the plot function, as such user can more easily set alerts on them.

It is important to note that achieving this requires accessing future price data, as such this script is subject to lookahead bias, historical results differ from the results one could have obtained in real-time.

版本注释

Minor changes.
评论
fannytradz
Very interesting .... however, I noticed that it is repainting all the time (I tried on smaller TF's) ....
Is there a way to fix it? I appreciate it.... Thanks
kolopolo253
paint
juiida
does it repaint??
Yidu_A_S_O_T_L_J_C
@juiida, Yes i think it does. Doesn't necessarily mean it's a bad thing. If you want to change that check if the source of the security request is a real time bar, if it's real time call the previous src in this case close[1] and set lookahead off - lookahead is still misleading.
juiida
@Yidu_A_S_O_T_L_J_C, after set lookahead off, indicator looks horrible XD
riyaandar
@juiida, how to set lookahead off
Pratik_4Clover
Thanks!
alessandro-17
How can I use it on a dayli chart?
dogekao
Looks so cool😍🎓🚨
Mikkott
is there any way to get an alert when the polyreg changes color?
更多