dandrideng

least_squares_regression

dandrideng Updated   
Library "least_squares_regression"
least_squares_regression: Least squares regression algorithm to find the optimal price interval for a given time period

basic_lsr(series, series, series) basic_lsr: Basic least squares regression algorithm
  Parameters:
    series: int t: time scale value array corresponding to price
    series: float p: price scale value array corresponding to time
    series: int array_size: the length of regression array
  Returns: reg_slop, reg_intercept, reg_level, reg_stdev

trend_line_lsr(series, series, series, string, series, series) top_trend_line_lsr: Trend line fitting based on least square algorithm
  Parameters:
    series: int t: time scale value array corresponding to price
    series: float p: price scale value array corresponding to time
    series: int array_size: the length of regression array
    string: reg_type: regression type in 'top' and 'bottom'
    series: int max_iter: maximum fitting iterations
    series: int min_points: the threshold of regression point numbers
  Returns: reg_slop, reg_intercept, reg_level, reg_stdev, reg_point_num
Release Notes:
v2 modify some discriptions
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.