Minor update:
Paints candles blue or red according to their close relative to an EMA on each the high, low and close.
Implementation of Raghee Horner's "Wave and GRaB Candles" Paints candles blue or red according to their close relative to an EMA on each the high, low and close.
study(title='Buy Blue Sell Red', shorttitle='BBSR', overlay=true) //ema periods emaPeriod = input(title="EMA Period", type=integer, defval=34) //build wave emaHigh = ema(high,emaPeriod) emaLow = ema(low,emaPeriod) emaClose = ema(close,emaPeriod) //optionally show ema lines showWave = input(title="Show Wave", type=bool, defval=false) waveHigh = iff(showWave == true, emaHigh, na) waveLow = iff(showWave == true, emaLow, na) waveClose = iff(showWave == true, emaClose, na) plot(waveHigh, color=red) plot(waveLow, color=blue) plot(waveClose, 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)