Highlight Momentum Candles + 3MAs
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TechnicallyMark

//@version=4
study(title="Highlight Momentum Candles", overlay=true)

bullPercentChange = input(defval = 3, title="% Change", group = "Bull Momentum")
bullWickTopPercent = input(defval = .5, title="Top Wick %", group = "Bull Momentum")
bullWickBtmPercent = input(defval = .5, title="Bottom Wick %", group = "Bull Momentum")

bearPercentChange = input(defval = -3, title="% Change", group = "Bear Momentum")
bearWickTopPercent = input(defval = -1.5, title="Top Wick %", group = "Bear Momentum")
bearWickBtmPercent = input(defval = -.5, title="Bottom Wick %", group = "Bear Momentum")

ema20 = input(defval = 20, title="Fast EMA", group = "EMA")
ema100 = input(defval = 100, title="Moderate EMA", group = "EMA")
ema200 = input(defval = 200, title="Slow EMA", group = "EMA")

//hammer = (close = open)
GreenMomentum =  (((close-open) / open * 100) >= bullPercentChange) and 
                   (((open-low) / low * 100) <= bullWickBtmPercent) and 
                   (((high-close) / close * 100) <= bullWickTopPercent) 

RedMomentum =  (((close-open) / open * 100) <= bearPercentChange) and 
                   (((open-high) / high * 100) >= bearWickTopPercent) and 
                   (((low-close) / close * 100) >= bearWickBtmPercent) 


barcolor(color=GreenMomentum ? color.green: na, title = "Bull Momentum", editable = true)

barcolor(color=RedMomentum ? color.red: na, title = "Bear Momentum", editable = true)

plot(sma(close, ema20), style=plot.style_line, color=color.orange)
plot(sma(close, ema100), style=plot.style_line, color=color.blue)
plot(sma(close, ema200), style=plot.style_line, color=color.purple)


bgcolor(color=GreenMomentum ? color.green : na, transp = 30)
bgcolor(color=RedMomentum ? color.red : na, transp = 30)
//(((close-close[1]) / close[1] * 100) > 3) and
//and (((open * .99 >= low)) and ((close * .97 >= high)))
//threeRedCandles = (close[2] < open[2]) and (close[1] < open[1])
     //and (close < open)
