Polynomial Regression Style Example
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=5
indicator(title='Polynomial Regression Style Example', overlay=true)

import RicardoSantos/FunctionPolynomialRegression/1 as poly

int length = input(10)
var float[] prices = array.new_float(size=length, initial_value=open)
var int[] indices = array.new_int(size=length, initial_value=0)
int fractal_size = input(2)
if ta.pivothigh(fractal_size, fractal_size)
    e = array.pop(id=prices)
    i = array.pop(id=indices)
    array.insert(id=prices, index=0, value=high[fractal_size])
    array.insert(id=indices, index=0, value=bar_index[fractal_size])
if ta.pivotlow(fractal_size, fractal_size)
    e = array.pop(id=prices)
    i = array.pop(id=indices)
    array.insert(id=prices, index=0, value=low[fractal_size])
    array.insert(id=indices, index=0, value=bar_index[fractal_size])

[lines_mid, lines_max, lines_min, lines_upper, lines_lower] = poly.draw(indices, prices)

// iterate over each line and adjust its properties:
for _i = 0 to array.size(lines_mid)-1
    //segment selection
    _mid = array.get(lines_mid, _i)
    line.set_width(_mid, 5)
    line.set_color(_mid, color.red)