Nico.Muselle

[NM]Improved Linear Regression Bull and Bear Power v02

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 ! :)

Check out my FREE indicator scripts:
www.tradingview.com/u/Nico.Muselle/

Twitter: twitter.com/NicoMuselle
オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?
//@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)