OPEN-SOURCE SCRIPT
Telah dikemas kini

Supertrend Dashboard

58
Overview

This dashboard is a multi-timeframe technical indicator dashboard based on Supertrend. It combines:

Trend detection via Supertrend

Momentum via RSI and OBV (volume)

Volatility via a basic candle-based metric (bs)

Trend strength via ADX

Multi-timeframe analysis to see whether the trend is bullish across different timeframes

It then displays this info in a table on the chart with colors for quick visual interpretation.

2️⃣ Inputs
Dashboard settings:

enableDashboard: Toggle the dashboard on/off

locationDashboard: Where the table appears (Top right, Bottom left, etc.)

sizeDashboard: Text size in the table

strategyName: Custom name for the strategy

Indicator settings:

factor (Supertrend factor): Controls how far the Supertrend lines are from price

atrLength: ATR period for Supertrend calculation

rsiLength: Period for RSI calculation

Visual settings:

colorBackground, colorFrame, colorBorder: Control dashboard style

3️⃣ Core Calculations
a) Supertrend

Supertrend is a trend-following indicator that generates bullish or bearish signals.

Logic:

Compute ATR (atr = ta.atr(atrLength))

Compute preliminary bands:

upperBand = src + factor * atr

lowerBand = src - factor * atr

Smooth bands to avoid false flips:

lowerBand := lowerBand > prevLower or close[1] < prevLower ? lowerBand : prevLower
upperBand := upperBand < prevUpper or close[1] > prevUpper ? upperBand : prevUpper


Determine direction (bullish / bearish):

dir = 1 → bullish

dir = -1 → bearish

Supertrend line = lowerBand if bullish, upperBand if bearish

Output: [st, bull]

st → line to plot

bull → boolean (true = bullish)

b) Buy / Sell Trigger

Logic:

bull = ta.crossover(close, supertrend) → close crosses above Supertrend → buy signal

bear = ta.crossunder(close, supertrend) → close crosses below Supertrend → sell signal

trigger → checks which signal was most recent:

trigger = ta.barssince(bull) < ta.barssince(bear) ? 1 : 0


1 → Buy

0 → Sell

c) RSI (Momentum)

rsi = ta.rsi(close, rsiLength)

Logic:

RSI > 50 → bullish

RSI < 50 → bearish

d) OBV / Volume Trend (vosc)

OBV tracks whether volume is pushing price up or down.

Manual calculation (safe for all Pine versions):

obv = ta.cum( math.sign( nz(ta.change(close), 0) ) * volume )
vosc = obv - ta.ema(obv, 20)


Logic:

vosc > 0 → bullish

vosc < 0 → bearish

e) Volatility (bs)

Measures how “volatile” the current candle is:

bs = ta.ema(math.abs((open - close) / math.max(high - low, syminfo.mintick) * 100), 3)


Higher % → stronger candle moves

Displayed on dashboard as a number

f) ADX (Trend Strength)

[_, _, adx] = ta.dmi(14, 14)

Logic:

adx > 20 → Trending

adx < 20 → Ranging

g) Multi-Timeframe Supertrend

Timeframes: 1m, 3m, 5m, 10m, 15m, 30m, 1H, 2H, 4H, 12H, 1D

Logic:

for tf in timeframes
[_, bull_tf] = request.security(syminfo.tickerid, tf, f_supertrend(ohlc4, factor, atrLength))
array.push(tf_bulls, bull_tf ? 1.0 : 0.0)


bull_tf ? 1.0 : 0.0 → converts boolean to number

Then we calculate user rating:

userRating = (sum of bullish timeframes / total timeframes) * 10


0 → Strong Sell, 10 → Strong Buy

4️⃣ Dashboard Table Layout
Row Column 0 (Label) Column 1 (Value)
0 Strategy strategyName
1 Technical Rating textFromRating(userRating) (color-coded)
2 Current Signal Buy / Sell (based on last Supertrend crossover)
3 Current Trend Bullish / Bearish (based on Supertrend)
4 Trend Strength bs %
5 Volume vosc → Bullish/Bearish
6 Volatility adx → Trending/Ranging
7 Momentum RSI → Bullish/Bearish
8 Timeframe Trends 📶 Merged cell
9-19 1m → Daily Bullish/Bearish for each timeframe (green/red)
5️⃣ Color Logic

Green shades → bullish / trending / buy

Red / orange → bearish / weak / sell

Yellow → neutral / ranging

Example:

dashboard_cell_bg(1, 1, colorFromRating(userRating))
dashboard_cell_bg(1, 2, trigger ? color.green : color.red)
dashboard_cell_bg(1, 3, superBull ? color.green : color.red)


Makes the dashboard visually intuitive

6️⃣ Key Logic Flow

Calculate Supertrend on current timeframe

Detect buy/sell triggers based on crossover

Calculate RSI, OBV, Volatility, ADX

Request Supertrend on multiple timeframes → convert to 1/0

Compute user rating (percentage of bullish timeframes)

Populate dashboard table with colors and values

✅ The result: You get a compact, fast, multi-timeframe trend dashboard that shows:

Current signal (Buy/Sell)

Current trend (Bullish/Bearish)

Momentum, volatility, and volume cues

Trend across multiple timeframes

Overall technical rating

It’s essentially a full trend-strength scanner directly on your chart.
Nota Keluaran
fix barstate.islast

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.