if average close is above average open, the bars are coloured green, otherwise they are coloured red
It can be used as a general trend filter on weekly, daily bars. even on intraday timeframes, this would work well and give a sense of the current trend direction.
//@version=2 study(title="Trend Filter", overlay = true) maPeriod = input(title="MA Period", type=integer, defval=20, minval=1) OpenMa = sma(open,maPeriod) CloseMa = sma(close,maPeriod) isBullish() => OpenMa < CloseMa isBearish() => OpenMa > CloseMa barcolor(isBullish() ? green : isBearish() ? red : na)