OPEN-SOURCE SCRIPT

Multi-TF Trend Table (Configurable)

201
1) What this tool does (in one minute)

A compact, multi‑timeframe dashboard that stacks eight timeframes and tells you:

Trend (fast MA vs slow MA)

Where price sits relative to those MAs

How far price is from the fast MA in ATR terms

MA slope (rising, falling, flat)

Stochastic %K (with overbought/oversold heat)

MACD momentum (up or down)

A single score (0%–100%) per timeframe

Alignment tick when trend, structure, slope and momentum all agree

Use it to:

Frame bias top‑down (M→W→D→…→15m)

Time entries on your execution timeframe when the higher‑TF stack is aligned

Avoid counter‑trend traps when the table is mixed

2) Table anatomy (each column explained)

The table renders 9 columns × 8 rows (one row per timeframe label you define).

TF — The label you chose for that row (e.g., Month, Week, 4H). Cosmetic; helps you read the stack.

Trend — Arrow from fast MA vs slow MA: ↑ if fastMA > slowMA (up‑trend), ↓ otherwise (down‑trend). Cell is green for up, red for down.

Price Pos — One‑character structure cue:

🔼 if price is above both fast and slow MAs (bullish structure)

🔽 if price is below both (bearish structure)

– otherwise (between MAs / mixed)

MA Dist — Distance of price from the fast MA measured in ATR multiples:

XS < S < M < L < XL according to your thresholds (see §3.3). Useful for judging stretch/mean‑reversion risk and stop sizing.

MA Slope — The fast MA one‑bar slope:

↑ if fastMA - fastMA[1] > 0

↓ if < 0

→ if = 0

Stoch %K — Rounded %K value (default 14‑1‑3). Background highlights when it aligns with the trend:

Green heat when trend up and %K ≤ oversold

Red heat when trend down and %K ≥ overbought Tooltip shows K and D values precisely.

Trend % — Composite score (0–100%), the dashboard’s confidence for that timeframe:

+20 if trendUp (fast>slow)

+20 if fast MA slope > 0

+20 if MACD up (signal definition in §2.8)

+20 if price above fast MA

+20 if price above slow MA

Background colours:

≥80 lime (strong alignment)

≥60 green (good)

≥40 orange (mixed)

<40 grey (weak/contrary)

MACD — 🟢 if EMA(12)−EMA(26) > its EMA(9), else 🔴. It’s a simple “momentum up/down” proxy.

Align — ✔ when everything is in gear for that trend direction:

For up: trendUp and price above both MAs and slope>0 and MACD up

For down: trendDown and price below both MAs and slope<0 and MACD down Tooltip spells this out.

3) Settings & how to tune them
3.1 Timeframes (TF1–TF8)

Inputs: TF1..TF8 hold the resolution strings used by request.security().

Defaults: M, W, D, 720, 480, 240, 60, 15 with display labels Month, Week, Day, 12H, 8H, 4H, 1H, 15m.

Tips

Keep a top‑down funnel (e.g., Month→Week→Day→H4→H1→M15) so you can cascade bias into entries.

If you scalp, consider D, 240, 120, 60, 30, 15, 5, 1.

Crypto weekends: consider 2D in place of W to reflect continuous trading.

3.2 Moving Average (MA) group

Type: EMA, SMA, WMA, RMA, HMA. Changes both fast & slow MA computations everywhere.

Fast Length: default 20. Shorten for snappier trend/slope & tighter “price above fast” signals.

Slow Length: default 200. Controls the structural trend and part of the score.

When to change

Swing FX/equities: EMA 20/200 is a solid baseline.

Mean‑reversion style: consider SMA 20/100 so trend flips slower.

Crypto/indices momentum: HMA 21 / EMA 200 will read slope more responsively.

3.3 ATR / Distance group

ATR Length: default 14; longer makes distance less jumpy.

XS/S/M/L thresholds: define the labels in column MA Dist. They are compared to |close − fastMA| / ATR.

Defaults: XS 0.25×, S 0.75×, M 1.5×, L 2.5×; anything ≥L is XL.

Usage

Entries late in a move often occur at L/XL; consider waiting for a pullback unless you are trading breakouts.

For stops, an initial SL around 0.75–1.5 ATR from fast MA often sits behind nearby noise; use your plan.

3.4 Stochastic group

%K Length / Smoothing / %D Smoothing: defaults 14 / 1 / 3.

Overbought / Oversold: defaults 70 / 30 (adjust to 80/20 for trendier assets).

Heat logic (column Stoch %K): highlights when a pullback aligns with the dominant trend (oversold in an uptrend, overbought in a downtrend).

3.5 View

Full Screen Table Mode: centers and enlarges the table (position.middle_center). Great for clean screenshots or multi‑monitor setups.

4) Signal logic (how each datapoint is computed)

Per‑TF data (via a single request.security()):

fastMA, slowMA → based on your MA Type and lengths

%K, %D → Stoch(High,Low,Close,kLen) smoothed by kSmooth, then %D smoothed by dSmooth

close, ATR(atrLen) → for structure and distance

MACD up → (EMA12−EMA26) > EMA9(EMA12−EMA26)

fastMA_prev → yesterday/previous‑bar fast MA for slope

TrendUp → fastMA > slowMA

Price Position → compares close to both MAs

MA Distance Label → thresholds on abs(close − fastMA)/ATR

Slope → fastMA − fastMA[1]

Score (0–100) → sum of the five 20‑point checks listed in §2.7

Align tick → conjunction of trend, price vs both MAs, slope and MACD (see §2.9)

Important behaviour

HTF values are sampled at the execution chart’s bar close using Pine v6 defaults (no lookahead). So the daily row updates only when a daily bar actually closes.

5) How to trade with it (playbooks)

The table is a framework. Entries/exits still follow your plan (e.g., S/D zones, price action, risk rules). Use the table to know when to be aggressive vs patient.

Playbook A — Trend continuation (pullback entry)

Look for Align ✔ on your anchor TFs (e.g., Week+Day both ≥80 and green, Trend ↑, MACD 🟢).

On your execution TF (e.g., H1/H4), wait for Stoch heat with the trend (oversold in uptrend or overbought in downtrend), and MA Dist not at XL.

Enter on your trigger (break of pullback high/low, engulfing, retest of fast MA, or S/D first touch per your plan).

Risk: consider ATR‑based SL beyond structure; size so 0.25–0.5% account risk fits your rules.

Trail or scale at M/L distances or when score deteriorates (<60).

Playbook B — Breakout with confirmation

Mixed stack turns into broad green: Trend % jumps to ≥80 on Day and H4; MACD flips 🟢.

Price Pos shows 🔼 across H4/H1 (above both MAs). Slope arrows ↑.

Enter on the first clean base‑break with volume/impulse; avoid if MA Dist already XL.

Playbook C — Mean‑reversion fade (advanced)

Use only when higher TFs are not aligned and the row you trade shows XL distance against the higher‑TF context. Take quick targets back to fast MA. Lower win‑rate, faster management.

Playbook D — Top‑down filter for Supply/Demand strategy

Trade first retests only in the direction where anchor TFs (Week/Day) have Align ✔ and Trend % ≥60. Skip counter‑trend zones when the stack is red/green against you.

6) Reading examples

Strong bullish stack

Week: ↑, 🔼, S/M, slope ↑, %K=32 (green heat), Trend 100%, MACD 🟢, Align ✔

Day: ↑, 🔼, XS/S, slope ↑, %K=45, Trend 80%, MACD 🟢, Align ✔

Action: Look for H4/H1 pullback into demand or fast MA; buy continuation.

Late‑stage thrust

H1: ↑, 🔼, XL, slope ↑, %K=88

Day/H4: only 60–80%

Action: Likely overextended on H1; wait for mean reversion or multi‑TF alignment before chasing.

Bearish transition

Day flips from 60%→40%, Trend ↓, MACD turns 🔴, Price Pos “–” (between MAs)

Action: Stand aside for longs; watch for lower‑high + Align ✔ on H4/H1 to join shorts.

7) Practical tips & pitfalls

HTF closure: Don’t assume a daily row changed mid‑day; it won’t settle until the daily bar closes. For intraday anticipation, watch H4/H1 rows.

MA Type consistency: Changing MA Type changes slope/structure everywhere. If you compare screenshots, keep the same type.

ATR thresholds: Calibrate per asset class. FX may suit defaults; indices/crypto might need wider S/M/L.

Score ≠ signal: 100% does not mean “must buy now.” It means the environment is favourable. Still execute your trigger.

Mixed stacks: When rows disagree, reduce size or skip. The tool is telling you the market lacks consensus.

8) Customisation ideas

Timeframe presets: Save layouts (e.g., Swing, Intraday, Scalper) as indicator templates in TradingView.

Alternative momentum: Replace the MACD condition with RSI(>50/<50) if desired (would require code edit).

Alerts: You can add alert conditions for (a) Align ✔ changes, (b) Trend % crossing 60/80, (c) Stoch heat events. (Not shipped in this script, but easy to add.)

9) FAQ

Q: Why do I sometimes see a dash in Price Pos? A: Price is between fast and slow MAs. Structure is mixed; seek clarity before acting.

Q: Does it repaint? A: No, higher‑TF values update on the close of their own bars (standard request.security behaviour without lookahead). Intra‑bar they can fluctuate; decisions should be made at your bar close per your plan.

Q: Which columns matter most? A: For trend‑following: Trend, Price Pos, Slope, MACD, then Stoch heat for entries. The Score summarises, and Align enforces discipline.

Q: How do I integrate with ATR‑based risk? A: Use the MA Dist label to avoid chasing at extremes and to size stops in ATR terms (e.g., SL behind structure at ~1–1.5 ATR).

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.