OPEN-SOURCE SCRIPT
21-Day Trend Direction

๐ 21-Day Trend Direction Indicator
๐ How It Works:
๐ฏ Trend Detection Logic:
Analyzes last 21 daily candles
Calculates total price change from start to end
Compares against sideways threshold (default 2%)
Counts bullish vs bearish days
Tracks higher highs and lower lows
๐ Trend Classifications:
โข ๐ UPTREND: Price change > +2% over 21 days
โข ๐ DOWNTREND: Price change < -2% over 21 days
โข โก๏ธ SIDEWAYS: Price change between -2% and +2%
๐ช Trend Strength Levels:
โข ๐ฅ Very Strong: >5% price change
โข ๐ช Strong: 3-5% price change
โข ๐ Moderate: 1.5-3% price change
โข ๐ Weak: <1.5% price change
๐จ Visual Features:
๐ Information Table Shows:
โข Trend Direction with color coding
โข Price Change % over 21 days
โข Trend Strength classification
โข Bull/Bear Days count
โข Higher Highs/Lower Lows count
โข Analysis Period (customizable)
๐ Chart Indicators:
โข Trend Line (21-day moving average)
โข Background Color for quick trend identification
โข Trend Arrows (โฒ โผ โก) on chart
โข Customizable display options
โ๏ธ Customizable Settings:
๐ฏ Analysis Settings:
โข Lookback Days: 5-50 days (default: 14)
โข Sideways Threshold: 0.5-10% (default: 2%)
โข Trend Strength: Low/Medium/High sensitivity
๐จ Display Options:
โข Table Position: 9 different positions
โข Table Size: Tiny to Large
โข Show/Hide: Table, Trend Line, Background, Arrows
๐จ Alert Options:
โข Trend Change to Uptrend
โข Trend Change to Downtrend
โข Trend Change to Sideways
This indicator gives you a clear, objective view of the 21-day trend with multiple confirmation signals! ๐
๐ How It Works:
๐ฏ Trend Detection Logic:
Analyzes last 21 daily candles
Calculates total price change from start to end
Compares against sideways threshold (default 2%)
Counts bullish vs bearish days
Tracks higher highs and lower lows
๐ Trend Classifications:
โข ๐ UPTREND: Price change > +2% over 21 days
โข ๐ DOWNTREND: Price change < -2% over 21 days
โข โก๏ธ SIDEWAYS: Price change between -2% and +2%
๐ช Trend Strength Levels:
โข ๐ฅ Very Strong: >5% price change
โข ๐ช Strong: 3-5% price change
โข ๐ Moderate: 1.5-3% price change
โข ๐ Weak: <1.5% price change
๐จ Visual Features:
๐ Information Table Shows:
โข Trend Direction with color coding
โข Price Change % over 21 days
โข Trend Strength classification
โข Bull/Bear Days count
โข Higher Highs/Lower Lows count
โข Analysis Period (customizable)
๐ Chart Indicators:
โข Trend Line (21-day moving average)
โข Background Color for quick trend identification
โข Trend Arrows (โฒ โผ โก) on chart
โข Customizable display options
โ๏ธ Customizable Settings:
๐ฏ Analysis Settings:
โข Lookback Days: 5-50 days (default: 14)
โข Sideways Threshold: 0.5-10% (default: 2%)
โข Trend Strength: Low/Medium/High sensitivity
๐จ Display Options:
โข Table Position: 9 different positions
โข Table Size: Tiny to Large
โข Show/Hide: Table, Trend Line, Background, Arrows
๐จ Alert Options:
โข Trend Change to Uptrend
โข Trend Change to Downtrend
โข Trend Change to Sideways
This indicator gives you a clear, objective view of the 21-day trend with multiple confirmation signals! ๐
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.