OPEN-SOURCE SCRIPT
已更新

MTID

539
Description
MTID is an all-in-one overlay built for swing and position traders who want price action, key statistics and fundamentals on a single pane. Six configurable moving averages, a "big move" marker, a live stats dashboard, and an 8-quarter fundamentals table are combined into one indicator with independent toggles for every section.

WHAT'S ON THE CHART
• Six moving averages — each with its own length, type (SMA/EMA), color and timeframe-visibility filter (All / Intraday+Daily / Weekly+Monthly / Intraday-only / Daily-only / Weekly-only). Default lengths 10/20/50/100/150/200 cover the most-watched values.
• Purple-Dot Big Move — flags bars whose move ≥ a configurable % AND volume ≥ a configurable threshold. Shape, size, color and timeframe-visibility are all configurable; bars can be color-coded on move direction.
• Optional bar coloring for high relative-volume bars.

STATS DASHBOARD (vertical table or horizontal headband)
• Sector & Industry (auto-detected from the symbol)
• Market Cap with currency conversion (Auto / USD / INR / EUR / GBP / JPY) and Indian (Cr/LCr) or Western (M/B/T) formatting
• 52-Week High/Low — % off the high and % off the low (daily-candle based regardless of chart TF)
• 13-Week Peak/Bottom — same idea over a quarter
• ADR (Average Daily Range %) and ATR — daily-candle based
• U/D Ratio — up-volume vs down-volume
• Float %
• Distance vs Daily SMA and Distance vs Weekly SMA — both shown simultaneously, regardless of chart timeframe
• Relative Volume (RVol)
• % above Low-of-Day (intraday session low; bar low on daily+)

FUNDAMENTALS TABLE
Last four quarters (with three more held internally for YoY math) of:
• EPS with YoY and QoQ % change
• Sales (auto-scaled units) with YoY and QoQ % change
• OPM% (Operating Margin = Operating Income / Revenue) with YoY and QoQ
• Per-quarter P/E (annualised from quarter EPS)
Plus an optional row showing the next two estimated quarters (EPS estimates, YoY/QoQ).
Header row showing Market Cap, Free-Float Mkt Cap, ROE and TTM P/E.
Vertical (full grid) or horizontal (transposed headband) layout.

IPO-FRIENDLY
Lookback windows adapt to available history. A newly listed symbol with fewer than 52 weeks (or 13 weeks, 50 bars for RVol, 20 days for ADR, etc.) still gets values computed over whatever data exists, instead of showing "N/A".

CUSTOMIZATION
• Every section independently togglable.
• Per-table position (6 anchor points), text size, layout (vertical / horizontal headband), border & frame width.
• Per-column text alignment (Left / Center / Right) for the dashboard.
• Configurable blank spacer rows at the top of each table — useful when TradingView's hover controls overlap the table.
• Fully themable colors (positive / negative / neutral, backgrounds, borders).

NOTES
• Sector, Industry, Market Cap, ROE, Float, EPS, Sales, Operating Income and EPS estimates are sourced from TradingView's request.financial / request.earnings and may be unavailable for some symbols or exchanges.
• Currency conversion uses FX_IDC daily rates.
• Built in Pine Script v6.
發行說明
# Removed

- **Volume Profile** — all inputs, state arrays, `computeVP`, the per-bar
array loop and the line/label drawing helpers. ~330 lines.
- **VWAP** — inputs, calculations, bands and the no-volume `runtime.error`
guard.
- `max_lines_count` / `max_labels_count` from the `indicator()` declaration
(only used by VP).
- `en_mtid` master toggle and the duplicate `show_stats` / `show_fin`
table-enable inputs.
- Dashboard "MTID | Dashboard" title row and the now-unused
`Title Background` / `Title Text` color inputs.
- Latest-quarter highlight (`C_HIGHLIGHT`) in the fundamentals table — every
cell now uses the standard background.

## Added

### Moving averages
- Increased from **6 to 8** moving averages.
- MA7 — 5 EMA, aqua, All Timeframes (default).
- MA8 — 30 SMA, lime, All Timeframes (default).

### Top-level toggles
- `Enable Table 1 (Dashboard)`
- `Enable Table 2 (Fundamentals)`

### Dashboard
- `Blank Rows at Top` (0–10, default 1) — transparent merged spacer rows.
- `Label Column Alignment` (Left / Center / Right, default Left).
- `Value Column Alignment` (Left / Center / Right, default Center).
- **Both** a daily-SMA distance row *and* a weekly-SMA distance row
(`vs SMAxx (D)` and `vs SMAxx (W)`) shown simultaneously, each with its
own toggle. Replaces the previous single timeframe-dependent row.

### Fundamentals table
- **OPM%** column / rows — Operating Margin = Operating Income / Revenue,
with YoY and QoQ. Toggle: `Show OPM% Data`.
- **Net Profit** column / rows — `NET_INCOME` from
`request.financial`, with YoY and QoQ. Toggle: `Show Net Profit Data`.
- `Blank Rows at Top` (0–10, default 1).
- `Quarters to Show` (1–8, default 4) — applies uniformly to EPS, Sales,
Net Profit, OPM% and P/E. Internally **12 quarters** are tracked so that
the YoY for the last visible quarter still has the matching prior-year
quarter to compare against.

## Changed

### Timeframe behaviour
- **U/D Ratio** now computed on **daily candles** (folded into the combined
daily `request.security`) so it no longer changes with chart TF.
- **Market Cap**, **Free-Float Mkt Cap**, **TTM P/E** and **per-quarter
P/E** now use the latest **daily close** instead of the chart's
intra-bar close. Fundamentals figures stay stable when you switch chart
timeframes.

### IPO / short-history friendliness
Every fixed-window metric below now adapts its length to available history
(`math.min(N, bar_index + 1)`) so freshly listed symbols produce values
immediately instead of waiting / showing N/A:

- 52-Week High & Low
- 13-Week Peak & Bottom
- ADR
- RVol
- U/D Ratio
- Distance vs Daily SMA / Weekly SMA

**ATR** can't use a dynamic length (Wilder's RMA requires a fixed window),
so it now falls back to `ta.sma(ta.tr(true), N)` with adaptive N while
Wilder's value is still `na`, then switches back to Wilder once enough
bars exist.

### Fundamentals number formatting
- **Sales** and **Net Profit** cells are now formatted to **2 decimal
places** with a magnitude suffix per value. The column header carries
the *base unit* and each cell is scaled within that base.
- Indian (INR / `use_indian_format`): header reads `Sales Cr` / `NP Cr`;
cells are expressed in Cr with a `K` (≥1e3 Cr) or `L` (≥1e5 Cr)
suffix. So `1.17 LCr` of revenue displays as `1.17 L` under a
`Sales Cr` header; `20,350 Cr` displays as `20.35 K`.
- Western (USD/EUR/etc.): header reads `Sales` / `NP`; cells use raw
currency with `K` (1e3) · `M` (1e6) · `B` (1e9) · `T` (1e12)
suffixes.
- `format_mkt_cap` (used for Market Cap and Free-Float Mkt Cap in the
fundamentals header) gained the `K` tier and is now a thin wrapper
around the shared scaler.
- Negative values keep their sign while being scaled by absolute
magnitude (e.g. a loss displays as `-1.23 K` under `NP Cr`).

### Performance
- Three separate daily `request.security` calls (52W/13W, ATR, ADR) were
merged into one combined call that also fetches the daily SMA, daily
close and U/D ratio in the same trip.
- Removing Volume Profile and VWAP eliminated the heavy per-bar work
(12 `array.push` + a profile-recompute loop on every new daily session).
Load time should drop substantially.

### Indicator metadata
- Title: `MTID + Volume Profile + VWAP [Combined]` → `MTID`.
- Short title: `MTID+VP+VWAP` → `MTID`.

## Fixed

- Latest fundamentals column was forcibly highlighted; now uses the
standard cell background.
- Distance-to-SMA only showed the weekly value on weekly charts and the
daily value otherwise — both are always shown now.
- Some metrics returned `na` for freshly listed symbols whose history was
shorter than the fixed lookback window (see *IPO / short-history
friendliness* above).

## Notes

- Sector, Industry, Market Cap inputs, ROE, EPS, Sales, Operating Income,
Net Income and EPS estimates are sourced from
`request.financial` / `request.earnings` and may be unavailable for some
symbols or exchanges; cells fall back to `—` in that case.
- Currency conversion still uses `FX_IDC` daily rates.
- Built in Pine Script v6.
發行說明
The script is not managed now. Sorry

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。