Nico.Muselle

[NM]Improved Linear Regression Bull and Bear Power v02

2305 18 417
Hi guys, I'm back with a little improvement on the Bull and Bear Signal I published just last week thanks to some feedback I received from a couple of users, which is of course highly appreciated.

Here are the changes that have been implemented compared to v01 :
(version 1 is the top indicator, version 2 is the bottom one) in the chart above

  • Formula adapted to calculate the signal if no data is available for either bull or bear
  • Added the possibility to smoothen the signal using Arnaud Legroux Moving Average (the benefit of this is that it does not add any lag to the signal)
  • Zero line was added

If you have any further ideas on how to improve the indicator or if you are happy with it and want to share your settings or rules of engagement, please feel free to share them below.

Oh, and don't forget to click that like button ! :)
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
// 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
// ***** Changelog compared to v01 ******
// Adapted formula to calculate the signal in case there is no information for either bear or bull
// Added the possibility to smoothen the signal (this is done by a simple SMA)
// Added zero line
study(title='[RS][NM]Improved Linear Regression Bull and Bear Power v02', shorttitle='BBP_NM_v02', overlay=false)
window = input(title='Lookback Window:', type=integer, defval=10)
smooth = input(title='Smooth ?', type=bool, defval=true)
smap = input(title='Smooth factor', type=integer, defval=5, minval=2, maxval=10)
sigma = input(title='Sigma', type=integer, defval=6)


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) > 0 ? f_exp_lr(h_value-close, n-h_bar) : 0)
bull = 0+(f_exp_lr(close-l_value, n-l_bar) > 0 ? f_exp_lr(close-l_value, n-l_bar) : 0)
direction = smooth ? alma(bull + bear, smap, 0.9, sigma) : bull*3 + bear*3
dcolor = smooth ? direction[0] > direction[1] ? green : direction[0] < direction[1] ? red : yellow : direction > bull ? green : direction < bear ? red : yellow

plot(title='Bear', series=bear, style=columns, color=maroon, transp=92)
plot(title='Bull', series=bull, style=columns, color=green, transp=92)
plot(title='Direction', series=direction, style=line, linewidth=3, color= dcolor)
plot(0,title='zero line', color=black, linewidth=2)

tradingmania
a year ago
Great improvement!
+1 Reply
Nico.Muselle MOD tradingmania
a year ago
Thanks a lot ! :)
Reply
AndrewHook
a year ago
Genial Nico. Thanks a lot +10
+1 Reply
Nico.Muselle MOD AndrewHook
a year ago
Thanks ! :)
Reply
AndrewHook
a year ago
Sorry Nico to bother you, but it seems the V2 is not available yet on the public library. I have try to change the V1 on my chart loading the new script but it is locked. Will you make it available soon as V2 ? Cheers
Reply
Nico.Muselle MOD AndrewHook
a year ago
Hi Andrew, try clicking on "Add to favourite scripts" (in the top right corner of the code box). Then in indicators, select Favorites, you should see it there. :)
Let me know if you have any further questions.
Reply
AndrewHook Nico.Muselle
a year ago
Oups I did it. Everything sorted. Thanks again for sharing have a nice day. Be the pips be with you ; )
+1 Reply
Nico.Muselle MOD AndrewHook
a year ago
You're welcome :)
Reply
amoldxb
a year ago
Hey Nico, Can I add this indicator to MT4 of any other broker or it has to be FXCM only. Because I could not find it last time you told. Can you guide me please
Reply
Nico.Muselle MOD amoldxb
a year ago
The indicators on TV can only be used on the TradingView website. They cannot be used on MT4.
Reply
loujill amoldxb
a year ago
I have a live FXCM account that I am currently trading with MT4. Can I trade my FXCM account through TradingView? I love this indicator!
+1 Reply
Nico.Muselle MOD loujill
a year ago
Thanks for your kind words. Unfortunately at this moment you cannot trade your FXCM account through TradingView (yet). Live trading on TradingView is planned though .... just a little patience :)
Reply
forexbhuro
a year ago
it will help, thanks for sharing
Reply
age0110
a year ago
HI Nico, so how do you use your new version? Thanks
Reply
roosikas
a year ago
Looks good, going to test it! TX!
Reply
gfglenn1 PRO
10 months ago
Have a question on your renko chart here I assume that your setting is 10 pips would that work on the 4 hour chart as well? PS I do like your linear program.
Reply
iykedy
10 months ago
Hi Nico, @Nico.Muselle. Thanks for this script. I have adapted it by plotting another line for a long term resolution but I have observed that the color on the long term resolution line is not accurate on real time data as compared to historical data. Here is the code. Do you know how I can fix the problem?

//@version=2
// 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
// ***** Changelog compared to v01 ******
// Adapted formula to calculate the signal in case there is no information for either bear or bull
// Added the possibility to smoothen the signal (this is done by a simple SMA)
// Added zero line
study(title='Improved Linear Regression Bull and Bear Power v02', shorttitle='Linear Regression Bull/Bear Power', overlay=false)
window = input(title='Lookback Window:', type=integer, defval=10)
smooth = input(title='Smooth ?', type=bool, defval=true)
smap = input(title='Smooth factor', type=integer, defval=5, minval=2, maxval=10)
sigma = input(title='Sigma', type=integer, defval=6)
longTermResolution = input(title='Long term resolution', type=resolution, defval='D')


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) > 0 ? f_exp_lr(h_value-close, n-h_bar) : 0)
bull = 0+(f_exp_lr(close-l_value, n-l_bar) > 0 ? f_exp_lr(close-l_value, n-l_bar) : 0)
longTermBear = security(tickerid, longTermResolution, bear)
longTermBull = security(tickerid, longTermResolution, bull)

direction = smooth ? alma(bull + bear, smap, 0.9, sigma) : bull*3 + bear*3
colorSeries = smooth ? direction > direction ? 0 : direction < direction ? 1 : 2 : direction > bull ? 0 : direction < bear ? 1 : 2
dcolor = colorSeries == 0 ? lime : colorSeries == 1 ? maroon : yellow

longTermDirection = smooth ? alma(longTermBull + longTermBear, smap, 0.9, sigma) : longTermBull*3 + longTermBear*3
longTermColorSeries = smooth ? longTermDirection > longTermDirection ? 0 : longTermDirection < longTermDirection ? 1 : 2 : longTermDirection > longTermBull ? 0 : longTermDirection < longTermBear ? 1 : 2
longTermColor = longTermColorSeries == 0 ? green : longTermColorSeries == 1 ? red : yellow

divergence = (longTermDirection < 0 and direction > 0 and colorSeries != colorSeries) or
(longTermDirection > 0 and direction < 0 and colorSeries != colorSeries) ? true : false

plot(title='Bear', series=bear, style=columns, color=maroon, transp=92)
plot(title='Bull', series=bull, style=columns, color=lime, transp=92)
plot(title='Direction', series=direction, style=line, linewidth=4, color= dcolor, transp=65)

plot(title='Bear', series=longTermBear, style=columns, color=maroon, transp=92)
plot(title='Bull', series=longTermBull, style=columns, color=green, transp=92)
plot(title='Direction', series=longTermDirection, style=line, linewidth=4, color= longTermColor)

barcolor(divergence ? yellow : na )

plot(0,title='zero line', color=divergence ? blue : orange, linewidth=2)

Reply
nboone
4 months ago
All I can say is wow. . . I did a little manual back testing on UJ daily using the default settings, changed the chart to Renko , and added LazyBear's ZeroLagEMA you suggested in the code comments. Following your instructions in the code comments results in a very high Win %, Great RR on each trade, and a very simple system.

I do not have a PRO account. So, I am unable to test on any time frame lower than D but I imaging there will be more false signals/losses on lower time frames. However, if further analysis supports the signals, lower time frames may still be quite profitable.

Thank you for you hard work on this indi!
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
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 Billing Sign Out