#TheStrat Scenarios relative to previous candle displayed as 1, 2u, 2d, or 3
#Current Bar Hammers and Shooters
#Closing price relative to opening price of current candle displayed as green, yellow, or red.
# RANGES #
def fullRange = high - low;
def closedRange = ((close - low) / fullRange);
def openedRange = ((open - low) / fullRange);
def bodyRange = (AbsValue(open - close)) / fullRange;
def highRange = (high - Max(open, close)) / fullRange;
def lowRange = (Min(open, close) - low) / fullRange;
def minLow = Min(closedRange, OpenedRange);
def maxHigh = Max(closedRange, OpenedRange);
# HAMMERS #
def softHammer = maxHigh > 0.75 and minLow > 0.55 and highRange < bodyRange;
def hardHammer = minLow > 0.66 and highRange <= 0.17 ;
def Hammer = hardHammer or softHammer;
# SHOOTING STARS #
def softShooter = minLow < 0.25 and maxHigh < 0.45 and lowrange < bodyRange;
def hardShooter = maxHigh < 0.34 and lowRange <= 0.17;
def Shooter = hardShooter or softShooter;
#Display Candle Type
plot CandleType;
if high[0]>high[1] and low[0]<low[1] then {CandleType = 3;} #outisde bar
else if high[0]<high[1] and low[0]>low[1] then {CandleType = 1;} #inside bar
else if high[0]>high[1] and low[0]>low[1] then {CandleType = 2;} #2-up
else {CandleType = 4;} #2-down
#Display Candle Direction
plot CandleDirection;
if close[0]>open[0] then {CandleDirection = 1;} #Price is rising, close>open
else if close[0]<open[0] then {CandleDirection = 2;} #Price is falling, close<open
else {CandleDirection = 3;} #No price movement, close=open
#Display Hammers/Shooters
plot CandleRange;
if Hammer then {CandleRange = 1;} #Hammer
else if Shooter then {CandleRange = 2;} #Shooter
else {CandleRange = 3;} #Neither Hammer or Shooter
#Display candle type, direction & range
addLabel(yes,
if CandleType == 3 then concat("3", if CandleRange==1 then "/H" else if CandleRange==2 then "/S" else "")
else if CandleType == 1 then concat("1", if CandleRange==1 then "/H" else if CandleRange==2 then "/S" else "")
else if CandleType == 2 then concat("2u", if CandleRange==1 then "/H" else if CandleRange==2 then "/S" else "")
else concat("2d", if CandleRange==1 then "/H" else if CandleRange==2 then "/S" else ""),
if CandleDirection == 2 then color.white
else if CandleDirection == 1 then color.black
else color.black);
assignBackgroundColor(
if CandleDirection == 1 then color.green
else if CandleDirection == 2 then color.red
else color.yellow);