1//@version=12// this code usesthe Linear Regression Bull and Bear Power indicator created by RicardoSantos3// and adds asignal line 4// Use : ifsignal line is changes color, you have your signal, green = buy, red = sell5// Advice : bestused with a zero lag indicator like ZeroLagEMA_LB from LazyBear6// if price isabove ZLEMA and signal = green => buy, price below ZLEMA and signal = red=> sell7study(title='[RS][NM]ImprovedLinear Regression Bull and Bear Power v01', shorttitle='BBP_NM', overlay=false)8window =input(title='Lookback Window:', type=integer, defval=10)910f_exp_lr(_height,_length)=>11 _ret = _height + (_height/_length)12 13h_value =highest(close, window)14l_value =lowest(close, window)1516h_bar =n-highestbars(close, window)17l_bar =n-lowestbars(close, window)1819bear =0-f_exp_lr(h_value-close, n-h_bar)20bull =0+f_exp_lr(close-l_value, n-l_bar)21direction =bull*2 + bear*222 2plot(title='Bear',series=bear, style=columns, color=maroon, transp=90)24plot(title='Bull',series=bull, style=columns, color=green, transp=90)25plot(title='Direction',series=direction, style=line, linewidth=3, color= direction > 0 ? green :red)
|