Bull & Bear Power Histogram for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Showing the current strength of the stock.



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;
 
K

KRHIlls

New member
VIP
@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

BenTen

Administrative
Staff
VIP
@KRHIlls Where do you see the 50 MA being used?
 
K

KRHIlls

New member
VIP
@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.
 
K

KRHIlls

New member
VIP
@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

BenTen

Administrative
Staff
VIP
@KRHIlls This script does not utilize the 50 simple moving average.
 
K

KRHIlls

New member
VIP
@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!
 
MerryDay

MerryDay

Active member
VIP
@KRHIlls

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



I actually did quite well in several of these stocks on Friday.
 
BenTen

BenTen

Administrative
Staff
VIP
Thank you @MerryDay for the example above. Hopefully, that will help @KRHIlls
 

Similar threads

Top