Trend Dashboard (Short / Medium / Long)

This script:
Calculates the short, medium, and long-term trend based on moving average crossovers
Displays the current trend status in a color-coded table on your TradingView chart
Helps you visually identify market trend direction at a glance — great for quick decision making
🧱 1. Inputs Section
shortMA_len = input.int(9, title="Short-Term MA")
mediumMA_short = input.int(21, title="Medium-Term Fast MA")
mediumMA_long = input.int(50, title="Medium-Term Slow MA")
longMA_short = input.int(50, title="Long-Term Fast MA")
longMA_long = input.int(200, title="Long-Term Slow MA")
This part lets you customize the moving averages used to determine each trend type:
Short-term: 9 vs 21 SMA
Medium-term: 21 vs 50 SMA
Long-term: 50 vs 200 SMA
You can change these from the indicator settings on your chart.
📈 2. Calculating the Moving Averages
shortMA = ta.sma(close, shortMA_len)
mediumFast = ta.sma(close, mediumMA_short)
mediumSlow = ta.sma(close, mediumMA_long)
longFast = ta.sma(close, longMA_short)
longSlow = ta.sma(close, longMA_long)
This section calculates:
The short MA (e.g. 9-period)
The medium fast & slow MAs (21 & 50)
The long fast & slow MAs (50 & 200)
📊 3. Determining the Trend
shortTrend = shortMA > mediumFast ? "Bullish" : shortMA < mediumFast ? "Bearish" : "Neutral"
mediumTrend = mediumFast > mediumSlow ? "Bullish" : mediumFast < mediumSlow ? "Bearish" : "Neutral"
longTrend = longFast > longSlow ? "Bullish" : longFast < longSlow ? "Bearish" : "Neutral"
Here, each trend is determined by a simple moving average crossover:
If the fast MA is above the slow MA → Bullish
If below → Bearish
If equal → Neutral
🎨 4. Trend Color Helper Function
getColor(trend) =>
trend == "Bullish" ? color.lime : trend == "Bearish" ? color.red : color.gray
Returns a color based on the trend type:
Green for Bullish
Red for Bearish
Gray for Neutral
📋 5. Creating and Updating the Table
var table trendTable = table.new(position.top_right, 2, 4, border_width=1)
This creates a 2-column, 4-row table in the top-right of the chart.
pinescript
Copy
Edit
table.cell(...)
Updates the table every few bars:
Row 1: headers
Row 2: Short-term trend
Row 3: Medium-term trend
Row 4: Long-term trend
Each trend is colored based on its status.
📌 6. Optional: Plot the Moving Averages
plot(shortMA, ...)
plot(mediumFast, ...)
...
Just to give you a visual reference, it plots each moving average on the chart in a different color.
✅ Summary: What You Get
🧠 Short-Term Trend: (e.g., 9 vs 21 SMA)
📈 Medium-Term Trend: (e.g., 21 vs 50 SMA)
📉 Long-Term Trend: (e.g., 50 vs 200 SMA)
🎨 Color-coded dashboard for instant recognition
📊 Great for trend-following, filtering trades, and quick analysis
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.