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

# [RS][NM]Improved Linear Regression Bull and Bear Power v01

4751 22
The base code for this indicator was created by RicardoSantos
What I added is a signal line that indicates when to buy and when to sell.

Combine with a zero-lag indicator like ZeroLagEMA_LB by LazyBear (suggested period = 34)
Then use the following Rules of engagement :
Current price > ZLEMA & Signal line of BBP_NM is green : BUY
Current price < ZLEMA & Signal line of BBP_NM is red : SELL Please click the like button if you dig this indicator !
Comment: I have found a little calculation error in this script where if there is no data for either bull or bear volume, the indicator will not plot. This has been corrected in version 2
```//@version=1
// this code uses the Linear Regression Bull and Bear Power indicator created by RicardoSantos
// and adds a signal line
// Use : if signal line is changes color, you have your signal, green = buy, red = sell
// Advice : best used with a zero lag indicator like ZeroLagEMA_LB from LazyBear
// if price is above ZLEMA and signal = green => buy, price below ZLEMA and signal = red => sell
study(title='[RS][NM]Improved Linear Regression Bull and Bear Power v01', shorttitle='BBP_NM', 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)
direction = bull*2 + bear*2

plot(title='Bear', series=bear, style=columns, color=maroon, transp=90)
plot(title='Bull', series=bull, style=columns, color=green, transp=90)
plot(title='Direction', series=direction, style=line, linewidth=3, color= direction > 0 ? green : red)```

## Related Ideas

Hello, when I copy the script into the MT4 meta editor then it does not work. It does not want to get attached to the chart. Please advise
where is the link of this indicator i couldnt locate it
Great.. I tried this today... with 1,4,and 16mt time frames together.I could predict the bottoms and tops with ease. I have a question: on the 16mt chart, the indicator rose to higher level, whereas the price was lower.. does it indicate more bear strength?
thank you for yr great job, and making it available to us all..
i studied the if i can come to more conclusions if the zero line is drawn.. yes really useful.. bear strengthbelow zero line is stronger evidently.. so i decided to add code to draw the zero line for myself,
or i suggest the author to add hlines for zero,, and possible max and min lines ..that would be really great as you shall see.. i made these studies without the lines drawn.. and i could make extra conclusions.. the author might know these values better

i have not tried along with LazyBear's zero lag indicator yet.. i'll do it.. ia couple of days

really Thank you..

PLEASE ANY ADVICE SAME PROBLEM WITH Ivan Ivanov0f IT COULDN'T ATTACHED TO MY MT4
kent20licious
That's because it's not written for MT4. It's only for use on Tradingview I'm afraid.
Hello, what timeframe do you suggest for the best results?
loujill
The time frame does not matter that much, it should work on all time frames.
I have used this indicator on the 1 min and 5 min time period trading Binary options and it is performing well for me. Give it a try!
fabfoot
Hey, thanks for your feedback. Good to hear some success stories ! Make sure to try out the improved v02 :)
Nico.Muselle
@Nico.Muselle, hi niko,just saw a comment of fabfoot, says he uses on binary,but, how to know expiry time?
RUSKY
RUSKY1
@RUSKY1, thanks for your visit and your question, unfortunately I don't have any experience using it for Binary options, as like you are saying there is also the matter of time. I hope @fabfoot can shine a light on this
Nico.Muselle
@Nico.Muselle, Thanks
fabfoot
@fabfoot, hi fabfoot,you said you used on binary and it did well, but, what expiry do you put.
Looks more for forex so,anyway, hope you give me the expiry time.
Thanks
RUSKY1
@RUSKY1, I no longer use it for Binary trading. I am on to the next thing. Good trading
fabfoot
@fabfoot, Thanks
Hi Nico, Now that Trading View has the new backtesting feature, can you please code a simple "strategy" script to use with this indicator?
loujill
Hi loujill, thanks for your request. I do not think it is a good idea to code a strategy for this indicator as it depends a lot on your trading style, the risk you are prepared to take, the targets you are looking for and the time frame you are trading. The challenge is on your side to find ways this indicator can harvest some pips for you ;)
On trying to learn this language, what the n stands for, also the symbol => on the following piece of code: f_exp_lr(_height, _length)=>
_ret = _height + (_height/_length). Thanks.
syracusepro
@syracusepro, sorry for the late reply
n returns the bar number (a built-in variable
the => symbol declares f_exp_lr as a function that requires 2 parameters, height and length and using those parameters calculates the return (_ret) using the formula height + (_height/_length)

This allows to create the calculation formula only once and use it with different parameters throughout the scripts as you can see :
bear = 0-f_exp_lr(h_value-close, n-h_bar)
bull = 0+f_exp_lr(close-l_value, n-l_bar)

hope this helps ... and again sorry for the (very) late reply
f_exp_lr(_height, _length)=>
_ret = _height + (_height/_length) Any other way to do this in pinescript?
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