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)
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
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
ประเทศไทย
Việt Nam
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out