How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

# [RS]Linear Regression Bull and Bear Power V0

656 11
EXPERIMENTAL:
Bull and Bear power based on linear regression (this is a non lagging oscillator, the parameter are for the lookup window for the donchian extremes)
this indicator can also be used for convergence/divergence.
```//@version=2
study(title='[RS]Linear Regression Bull and Bear Power V0', shorttitle='BBP', overlay=false)
window = input(title='Lookback Window:', type=integer, defval=10)

f_exp_lr(_height, _length)=>
_ret = _height + (_height/_length)

h_value = highest(close, window)
l_value = lowest(close, window)

h_bar = n-highestbars(close, window)
l_bar = n-lowestbars(close, window)

bear = 0-f_exp_lr(h_value-close, n-h_bar)
bull = 0+f_exp_lr(close-l_value, n-l_bar)

plot(title='Bear', series=bear, style=columns, color=maroon)
plot(title='Bull', series=bull, style=columns, color=green)
```
Great. Thanks for your continuing contribution!
Ricardo, just thinking out loud... would it be difficult to incorporate an accumation option into this script?

For example: sum up al bull bars (above the 0-line) and bear bars (below the 0-line) within a given time period (which would be an input).
accidentjev2
its possible, ill have stab at it on the weekend
RicardoSantos
done:
RicardoSantos
Superb. Thanks man
RicardoSantos
Ricardo, I've been playing with it and it would be very useful to make the script "multi-timeframe-able". Only I'm not succeeding in modifying it succesfully :). Could you take a last look?
accidentje
> the accumulation version I mean
accidentje
i can add a security() to get the values for higher timeframes, or you can use higher length values on the inputs to fit the higher timeframes.
the security is just a matter of adding 1/2 lines to the script(altho by using security its subject to repaint values when it re updates).
RicardoSantos
I leave that decision up to you Ricardo since I don't fully grasp the implications. The idea is to have a view of the net bull-bear accumulation on the daily (for example), and underneath that the net accumulation on the weekly (or any higher timeframe, for example). So making the prefered timeframe an input would be ideal (preferably without having to calibrate length values). Thanks in advance!
accidentje
done:
RicardoSantos
Sweet, thanks again. Was indeed rather simple I now see ;)
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter