Madrid Bull Bear Sentiment

1068 0 267
This indicator displays the distance in percentage between the highest and lowest points in a given period of time, compares them and determines which side has more dominance.
Remove from Favorite Scripts Add to Favorite Scripts
// Madrid : 24/Apr/2015 : 00:07 : Bull Bear Sentiment : 2.0
// This measures the difference in PCT from the last Lowest/Highest Point
// to determine the overall sentiment
study("Madrid Bull Bear Sentiment", shorttitle="MSentiment", precision=0)
len = input(18)

OB=76.4, OS=23.6
smooth = input(true, title="Smooth")

lowerBand = 5
PI= 3.14159265358979
ssFilter( price, lowerBand ) =>
    angle = sqrt(2)*PI/lowerBand
    a1= exp(-angle)
    b1 = 2*a1*cos(angle)
    c2 = b1
    c3 = -a1*a1
    c1 = 1 - c2 -c3
    filt = c1*(price + nz(price[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2])

sentiment(len) =>
    lowest = lowest(src,len)
    highest = highest(src,len)
    diffBull = (src-lowest)*100/lowest
    diffBear = (highest-src)*100/highest
    bbs = diffBull*100/(diffBear + diffBull)
    bbSentiment = smooth?ssFilter(bbs,lowerBand):bbs

bbSentiment = sentiment(len)

// Output
hline(OB, color=white, linestyle=dotted)
hline(50, color=white, linestyle=dotted)
hline(OS, color=white, linestyle=dotted)

plot(100, color=red, style=area, transp=0)
plot(bbSentiment, color=green, style=area, transp=0)
plot(bbSentiment, color=change(bbSentiment)>=0?lime:maroon, linewidth=1)

EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out