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;