Madrid Bull Bear Sentiment For ThinkOrSwim

petergluis

Active member
Madrid Bull Bear Sentiment provides the overall bull bear sentiment.
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.
h0PxoZI.png

It will be nice to have ThinkorSwim version. Thank you very much for your help.

Here is the link of the indicator with Pinescript.
https://www.tradingview.com/script/f9OdIHQf-Madrid-Bull-Bear-Sentiment/
 
Last edited by a moderator:
Madrid Bull Bear Sentiment provides the overall bull bear sentiment. It will be nice to have ThinkorSwim version. Thank you very much for your help.

Here is the link of the indicator with Pinescript.

https://www.tradingview.com/script/f9OdIHQf-Madrid-Bull-Bear-Sentiment/
@petergluis Try this and let me know.

Ruby:
#Madrid Bull Bear Sentiment
#Coverted by @SuryaKiranC
#Requested by @petergluis
#Requested at https://usethinkscript.com/threads/madrid-bull-bear-sentiment-for-thinkorswim.9254
#Original Source https://www.tradingview.com/script/f9OdIHQf-Madrid-Bull-Bear-Sentiment/

declare lower;
declare real_size;
input src = close;
input len = 18;

def OB = 76.4;
def OS = 23.6;

input smooth = yes;
input lowerBand = 5;

script nz {
    input data = 0;
    def ret_val = if isNaN(data) then 0 else data;
    plot return = ret_val;
}

script ssFilter {
    input price = close;
    input lowerBand = 5;
    def PI= 3.14159265358979;

    def angle = sqrt(2) *PI/lowerBand;
    def a1= exp(-angle);
    def b1 = 2*a1*cos(angle);
    def c2 = b1;
    def c3 = -a1*a1;
    def c1 = 1 - c2 -c3;
    def filt = c1*(price + nz(price[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2]);
    plot c = filt;
};

script sentiment {
    input lowerBand = 5;
    input len = 18;
    input src = close;
    def lowest = lowest(src,len);
    def highest = highest(src,len);
    def diffBull = (src-lowest)*100/lowest;
    def diffBear = (highest-src)*100/highest;
    def bbs = diffBull*100/(diffBear + diffBull);

plot bbSentiment = ssFilter(bbs,lowerBand = lowerBand);
};

plot sentiment = sentiment(len = len);

plot OverBought = OB ;
OverBought.SetDefaultColor(Color.WHITE);
plot mid = 50;
mid.SetDefaultColor(Color.WHITE);
plot OverSold = OS;
OverSold.SetDefaultColor(Color.WHITE);
AddCloud(sentiment,lowestall(sentiment), Color.GREEN);
AddCloud(highestall(sentiment),sentiment, Color.RED);
#End


Add the below code at the end of the main study script. For scan set a custom study filter, with MadridBulBearSentiment()."Bear" or MadridBulBearSentiment()."Bull" as a string.

Ruby:
def Bull = if sentiment > OverSold and sentiment > sentiment[1] then 1 else Double.NaN;
def Bear = if sentiment < OverBought and sentiment < sentiment[1] then -1 else Double.NaN;

plot scan = (Bull or Bear);
scan.SetHiding(1);

If you want audible alerts, add the following too.

Ruby:
input audibleAlerts = yes;

AddLabel(Yes,Sentiment,Color.Yellow);
Alert(audibleAlerts and Bull, "Sentiment Bullish", Alert.BAR, Sound.Ding);
Alert(audibleAlerts and Bear, "Sentiment Bearish", Alert.BAR, Sound.Ring);
 
Last edited:
It is very nice. Thank you very much for this wonderful job. I would like to know whether you can have a scan feature based on this indicator.
How, out of curiosity, are you using this... primary signals, confirmation, it looks interesting but there isn't much around on how it's being used. Any thoughts you'd want to share with us all?

thanks
-mashume
 
I often use it to find when a stock or an ETF to reach short-term bottoms or tops. I modified this indicator by adding more signal lines so that we detect whether the uptrend can continue. I will learn how to insert images to this reply later as I tried a couple of times and failed by using inserting icon above.
 
The modified bull-bear sentiment indicator closely aligns with the version on tradingview.com, with a notable distinction in the minimum values. In the original indicator, the bear sentiment can reach zero, whereas in the converted version, it plateaus at 37.7. I would appreciate it if you could kindly look into and address this discrepancy. Thank you for your assistance.
 
The modified bull-bear sentiment indicator closely aligns with the version on tradingview.com, with a notable distinction in the minimum values. In the original indicator, the bear sentiment can reach zero, whereas in the converted version, it plateaus at 37.7. I would appreciate it if you could kindly look into and address this discrepancy. Thank you for your assistan
The modified bull-bear sentiment indicator closely aligns with the version on tradingview.com, with a notable distinction in the minimum values. In the original indicator, the bear sentiment can reach zero, whereas in the converted version, it plateaus at 37.7. I would appreciate it if you could kindly look into and address this discrepancy. Thank you for your assistance.
I am assuming you are saying that anything > 37.7 is buy
Change the OS = 37.7 instead of it's current value as 23.6.. then it's a simple edit in the program... look for the OS value and change.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
313 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top