Bull & Bear Power Histogram for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Showing the current strength of the stock.

IaKhvko.png


Code:
# Bull & Bear Power Histogram
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/hMma413M/

declare lower;

input Length = 30;

def r1 =if(close[1]<open, max(open-close[1], high-low),high-low);
def r2 =if(close[1]>open, max(close[1]-open, high-low),high-low);

def bull =if(close==open, if(high-close==close-low, if(close[1]>open, max(high-open, close-low),r1),if(high-close>close-low, if(close[1]<open, max(high-close[1], close-low), high-open),r1)),if(close<open, if(close[1]<open, max(high-close[1], close-low), max(high-open, close-low)),r1));
def bear =if(close==open, if(high-close==close-low, if(close[1]<open, max(open-low, high-close),r2),if(high-close>close-low, r2, if(close[1]>open, max(close[1]-low, high-close), open-low))),if(close<open, r2, if(close[1]> open, max(close[1]-low, high-close),max(open-low, high-close))));

def distance = simpleMovingAvg(bull - bear, Length);

plot diff = distance;

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);

Diff.DefineColor("red", Color.red);
Diff.DefineColor("green", Color.green);

Diff.AssignValueColor(if distance< 0 then Diff.color("red") else Diff.color("green"));

plot ZeroLine = 0;
 

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

@BenTen I notice this indicator shows bullish moves above the 50 MA and bearish moves below it. Is there anyway to setup this indicator to catch bullish or bearish moves around the 10 MA? Thanks!
 
@BenTen When i use the indicator, i notice the histogram doesn't turn green until candles go above the 50 MA. When it's below the 50 MA the indicator show bearish. I was just checking out the indicator with a 50 MA. If you try it you'll see what i'm talking about. The indicator is very powerful above the 50 MA.
 
@BenTen When the candle is above the 50 MA and the indicator is showing green the market is strong uptrend. And below the 50 MA and the indicator showing red it's a strong downtrend. I'm using the 5 minute chart
 
@BenTen I understand this script doesn't utilize the 50 SMA. I didn't see it in the code. If you just give it a try you'll see what i'm talking about. I've been trying to figure out how is this possible and the 50 SMA isn't utilized. But above the 50 the indicator show bullish and below the 50 it shows bearish. There's another indicator on this forum by the name Webby's RSI, it does the same thing. Please just look at them. If not i'll keep trying to figure them out. I don't know anything about coding but i'll keep trying. Thanks!
 
@KRHIlls

The following scan provides almost 400 stocks on the 5min chart that have the indicator showing Bullish with price below the 50SMA

CESlCfO.png


I actually did quite well in several of these stocks on Friday.
 
Showing the current strength of the stock.

IaKhvko.png


Code:
# Bull & Bear Power Histogram
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/hMma413M/

declare lower;

input Length = 30;

def r1 =if(close[1]<open, max(open-close[1], high-low),high-low);
def r2 =if(close[1]>open, max(close[1]-open, high-low),high-low);

def bull =if(close==open, if(high-close==close-low, if(close[1]>open, max(high-open, close-low),r1),if(high-close>close-low, if(close[1]<open, max(high-close[1], close-low), high-open),r1)),if(close<open, if(close[1]<open, max(high-close[1], close-low), max(high-open, close-low)),r1));
def bear =if(close==open, if(high-close==close-low, if(close[1]<open, max(open-low, high-close),r2),if(high-close>close-low, r2, if(close[1]>open, max(close[1]-low, high-close), open-low))),if(close<open, r2, if(close[1]> open, max(close[1]-low, high-close),max(open-low, high-close))));

def distance = simpleMovingAvg(bull - bear, Length);

plot diff = distance;

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);

Diff.DefineColor("red", Color.red);
Diff.DefineColor("green", Color.green);

Diff.AssignValueColor(if distance< 0 then Diff.color("red") else Diff.color("green"));

plot ZeroLine = 0;
Ben - Could we use any length other than 30? Is 30 the MA?
 
Ben - Could we use any length other than 30? Is 30 the MA?
The script that you quoted looks at the moving average of ratio of bull to bear price action.
Yes, the moving average looks at a length of 30 bars which is a standard default for most day and short-medium swing traders.
Try shortening for shorter-term trades.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
397 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