MohitMarwaha

Trend Filter

The indicator paints the bar colours based on the average open and average close for past N days.
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.
Remove from Favorite Scripts Add to Favorite Scripts
//@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)
GoldBowtie
10 months ago
WHy only color the bars? You should add a visible line so to be able to keep track of potential turning points before they happen.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out