 # GRaB Candles by mattlacoco with Murrey Math Midline (use V1.1 now See links below)

GRaB candles and a murrey math "midline" in one script.
Some traders using methods of Rob Booker (40% club, trifecta5) like to use both GRaB candles and Murrey Math to combine, or to compare entry and exit moments.
Color of candles are as GRaB candles.
Midline use: Crossing the midline is a change of color in murrey. Candles closing above the midline would be green and below would be red as murrey candles.

Credits:
Original script of Raghee Horner's GRaB Candles by Matt Lacoco (BUY BLUE SELL RED).
Murrey Math Midline added by Harold van Berk (most code copied from "UCS_Murrey's Math Oscillator_V2" by ucsgears)
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

Want to use this script on a chart?
```study(title='Buy Blue Sell Red', shorttitle='BBSR', overlay=true)

// plot midline from Murrey Math for trifecta entry and exit
// Inputs
length = input(100, minval = 10, title = "Look back Length")
mult = input(0.125, title = "Mutiplier; Only Supports 0.125 = 1/8")
lines = input(true, title= "Show Murrey Math Fractals")
bc = input(true, title = "Show Bar Colors Based On Oscillator")

// Donchanin Channel
hi = highest(high, length)
lo = lowest(low, length)
range = hi - lo
multiplier = (range) * mult
midline = lo + multiplier * 4

plot (midline)
// end MMM line

// vars
emaPeriod = input(title="EMA Period", type=integer, defval=34)
showWave = input(title="Show Wave", type=bool, defval=false)

// build wave
emaHigh = ema(high,emaPeriod)
emaLow = ema(low,emaPeriod)
emaClose = ema(close,emaPeriod)

waveHigh = showWave == true ? emaHigh : na
waveLow = showWave == true ? emaLow : na
waveClose = showWave == true ? emaClose : na

plot(waveHigh, title="EMA High",color=red )
plot(waveLow, title="EMA Low", color=blue)
plot(waveClose, title="EMA Close", color=silver)

// paint candles according to close position relative to wave
barcolor(close < emaLow ? close > open ? red : maroon : close > emaHigh ? close > open ? blue : navy : close > open ? silver : gray)
```