RicardoSantos

[RS]Linear Regression Bull and Bear Power V0

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.
Remove from Favorite Scripts Add to Favorite Scripts
//@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)
accidentje
2 years ago
Great. Thanks for your continuing contribution!
Reply
accidentjev2
a year ago
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).
Reply
RicardoSantos PRO accidentjev2
a year ago
its possible, ill have stab at it on the weekend
Reply
RicardoSantos PRO RicardoSantos
a year ago
done:
[RS]Linear Regression Bull and Bear Power Accumulation V0
+1 Reply
accidentje RicardoSantos
a year ago
Superb. Thanks man
Reply
accidentje RicardoSantos
a year ago
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?
Reply
accidentje accidentje
a year ago
> the accumulation version I mean
Reply
RicardoSantos PRO accidentje
a year ago
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).
Reply
accidentje RicardoSantos
a year ago
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!
Reply
RicardoSantos PRO accidentje
a year ago
done:
[RS]Linear Regression Bull and Bear Power Accumulation V1
Reply
accidentje RicardoSantos
a year ago
Sweet, thanks again. Was indeed rather simple I now see ;)
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener 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
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out