本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// ═══════════════════════════════════════════════════════════════════════════════════════════
// AURIX FlowMatrix
// Advanced Multi-Market TradingView Indicator (Pine Script® v6)
// ═══════════════════════════════════════════════════════════════════════════════════════════
//
// AUTHOR / PUBLISHER / RIGHTS HOLDER : Michael_Fx_Trader
// COPYRIGHT : © 2026 Michael_Fx_Trader. All rights reserved.
//
// ───────────────────────────────────────────────────────────────────────────────────────────
// ORIGINALITY DECLARATION AND AUTHOR VERIFICATION
// ───────────────────────────────────────────────────────────────────────────────────────────
// I, Michael_Fx_Trader, hereby declare and verify that:
//
// 1. "AURIX FlowMatrix" is an ORIGINAL work, conceived, specified and implemented for the
// author. It is NOT a copy, fork, clone, re-skin, decompiled or re-published version of
// any third-party script, open-source or closed-source.
// 2. The calculation logic in this script (anchored volume-weighted reference, weighted
// dispersion bands, anchored volume profile, rolling volume profile, estimated directional
// volume, relative volume, signal rules, dashboard and drawing layer) was written from the
// author's own written specification, "AURIX FlowMatrix Developer Brief".
// 3. Only standard, publicly documented Pine Script® v6 built-in functions are used. No code
// from other authors' scripts is included.
// 4. The author is the sole owner of all rights, title and interest in this script, its name,
// its visual layout, its documentation and its source code, and is also its publisher.
// 5. Any redistribution, resale, modification for redistribution, or removal of this header
// without the written permission of Michael_Fx_Trader is prohibited.
//
// Signed (declared author) : Michael_Fx_Trader
// Product name : AURIX FlowMatrix
// Product type : Indicator (NOT an automated strategy and NOT a broker-execution tool)
//
// ───────────────────────────────────────────────────────────────────────────────────────────
// IMPORTANT DISCLAIMER
// ───────────────────────────────────────────────────────────────────────────────────────────
// This indicator is an analytical tool only. BUY / SELL labels mark RULE-BASED CONDITIONS, not
// guaranteed outcomes. No signal predicts future price movement with certainty. Nothing here is
// financial advice. Trade at your own risk and always use your own risk management.
//
// ───────────────────────────────────────────────────────────────────────────────────────────
// CALCULATION SUMMARY (full documentation of every default and rule)
// ───────────────────────────────────────────────────────────────────────────────────────────
// 1) ANCHOR PERIOD
// Session : first bar of the symbol's exchange session (session.isfirstbar) on intraday charts.
// On daily-or-higher charts "Session" falls back to the Week anchor.
// Week / Month / Quarter / Year : timeframe.change("W" / "M" / "3M" / "12M").
// Everything anchored (VWAP, bands, delta, anchored profile) resets on the first bar of a new
// anchor. On a chart whose timeframe equals the anchor period (e.g. Weekly chart + Week anchor)
// every bar is its own anchor, so anchored values degenerate to single-bar values.
// No signal is allowed on the first bar of a new anchor (warm-up guard).
//
// 2) VOLUME-WEIGHTED REFERENCE (VWAP)
// VWAP = Σ(w·p) / Σ(w), where p = selected price source and w = bar volume.
// Bars with zero/missing volume get weight 0 (unless the optional equal-weight fallback is
// enabled AND the feed has produced no volume at all, in which case the dashboard says so).
//
// 3) DEVIATION BANDS
// Weighted variance = Σ(w·p²)/Σ(w) − VWAP² (volume-weighted, population form).
// σ = sqrt(max(variance, 0)). Bands = VWAP ± k·σ with k = inner / outer multiplier
// (defaults 1.0 and 2.0). This differs from an unweighted standard deviation because every
// observation is weighted by its volume, so high-volume bars influence dispersion more.
// σ is unavailable (na) until the anchor holds at least 2 bars or when σ = 0.
//
// 4) ANCHORED VOLUME PROFILE + ANCHOR POC
// Eligible range : lowest low → highest high of the anchor (or the outer bands if selected).
// Rows : the range is divided into N equal price intervals.
// Allocation : each candle's volume is spread across the intervals its [low, high] range
// overlaps, in proportion to the overlap (uniform-within-candle approximation).
// A candle with high == low goes entirely into its interval.
// Anchor POC : mid-price of the interval with the greatest accumulated volume (first
// interval wins ties). This is a candle-based approximation, NOT a
// tick-by-tick market profile.
// Cap : at most "Max bars in anchored profile" most recent bars of the anchor are
// used (default 4000, hard limit 4900 because of Pine's history buffer). The
// profile is only computed for the latest bar (efficient) and updates live.
//
// 5) ROLLING POC
// Same allocation method, but over the last N bars (default 50) and independent of the
// anchor. RAW rolling POC = highest-volume interval of that window (it can jump between
// intervals). PLOTTED Rolling POC = SMA(raw POC, smoothing length) (default 5), which is
// smoother but lags the raw value. Computed on every bar so history is reproducible.
//
// 6) ESTIMATED DIRECTIONAL DELTA
// Candle direction: close > open = positive, close < open = negative; for a doji the sign of
// (close − previous close) is used; if still zero the candle is neutral (excluded).
// Delta % = (PositiveVolume − NegativeVolume) / (PositiveVolume + NegativeVolume) × 100.
// Anchor delta = over the anchor period. Recent delta = over the last N bars (default 40).
// This is an ESTIMATE from candle direction only. It is NOT bid/ask transaction delta and NOT
// proof of institutional buying or selling.
//
// 7) RELATIVE VOLUME
// Standard : volume of the last COMPLETED candle ÷ SMA of the N candles BEFORE it
// (the evaluated candle is excluded from the baseline). Default N = 20.
// Time-of-day: (optional, intraday only) volume ÷ average volume of the same exchange-time
// minute-of-day over the previous N sessions (minimum 3 samples).
// Relative volume says nothing about direction.
//
// 8) BUY / SELL RULES (confirmed-bar mode is the default)
// BUY : close crosses ABOVE the Rolling POC (close[1] <= POC, close > POC)
// AND the signal candle CLOSES BELOW the anchored VWAP
// AND the bar is confirmed (closed).
// SELL : close crosses BELOW the Rolling POC (close[1] >= POC, close < POC)
// AND the signal candle CLOSES ABOVE the anchored VWAP
// AND the bar is confirmed (closed).
// "Signal sensitivity": Standard = cross of the SMOOTHED Rolling POC (plotted line);
// High = cross of the RAW Rolling POC (faster, more BUY and SELL labels).
// "Strict price-driven crossover" (default OFF = plain ta.crossover / ta.crossunder as in the
// brief): when ON it also requires the PREVIOUS close to be on the other side of the CURRENT
// POC value, so a signal is never produced only because the POC line itself jumped.
// One label per newly confirmed crossover event. Touching a band never creates a signal.
// Optional cooldown (default 0 = off) enforces a minimum bar spacing per direction.
// Optional filters (default OFF): higher-timeframe trend alignment, minimum relative volume.
// Optional provisional preview mode draws a temporary "(prov.)" label on the forming candle;
// it is removed/replaced and never becomes a confirmed signal or alert.
//
// 9) NON-REPAINTING NOTES
// Confirmed signals use barstate.isconfirmed and only data available at the bar close. The
// higher-timeframe filter reads the PREVIOUS COMPLETED HTF bar (close[1] + lookahead_on),
// which adds one HTF bar of delay but never uses unfinished HTF data. Live values of lines,
// the profile and the dashboard change while a candle forms; that is normal live updating,
// not repainting. Historical data-feed revisions by the data vendor can change history.
//
// 10) KNOWN PLATFORM LIMITS
// • Max 500 labels are kept by TradingView; only the most recent 500 signal labels display.
// • Forex / CFD / many index feeds provide TICK volume (activity proxy), not true traded volume.
// • Profile is built from candles (OHLCV), not from individual transactions.
// ═══════════════════════════════════════════════════════════════════════════════════════════
indicator(title = "AURIX FlowMatrix", shorttitle = "AURIX FM", overlay = true, max_bars_back = 5000, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500)
// ═══════════════════════════════════════════════════════════════════════════════════════════
// CONSTANTS
// ═══════════════════════════════════════════════════════════════════════════════════════════
const int MIN_OBS = 2
const string DU_ABS = "Absolute price"
const string DU_PCT = "Percent"
const string DU_TICK = "Minimum ticks"
const string DU_ATR = "ATR multiple"
const string RV_STD = "Standard rolling"
const string RV_TOD = "Time-of-day (intraday)"
const string SS_STD = "Standard (smoothed Rolling POC)"
const string SS_HIGH = "High (raw Rolling POC, more signals)"
const string SM_CONF = "Confirmed only (default)"
const string SM_PROV = "Confirmed + provisional preview"
const string PR_FULL = "Full anchor range"
const string PR_BANDS = "Outer deviation bands"
const string G_A = "A — General Settings"
const string G_B = "B — Deviation Bands"
const string G_C = "C — Anchored Volume Distribution"
const string G_D = "D — Anchor POC"
const string G_E = "E — Rolling POC"
const string G_F = "F — Directional Volume Analysis"
const string G_G = "G — BUY / SELL Signals"
const string G_H = "H — Dashboard"
const string G_I = "I — Advanced Settings"
const string G_J = "J — Candle Coloring"
// ═══════════════════════════════════════════════════════════════════════════════════════════
// INPUTS
// ═══════════════════════════════════════════════════════════════════════════════════════════
// ── A — General ─────────────────────────────────────────────────────────────────────────────
string anchorIn = input.string("Session", "Anchor / reset period", options = ["Session", "Week", "Month", "Quarter", "Year"], group = G_A, tooltip = "Period from which the VWAP, bands, anchored profile and anchor delta are accumulated. 'Session' uses the symbol's exchange session on intraday charts (falls back to Week on daily+ charts).")
float srcIn = input.source(hlc3, "VWAP price source", group = G_A, tooltip = "Price input used for the volume-weighted reference and band dispersion. Default: typical price (HLC/3).")
// ── B — Bands ───────────────────────────────────────────────────────────────────────────────
float innerMult = input.float(1.0, "Inner band multiplier (σ)", minval = 0.1, step = 0.1, group = G_B, tooltip = "Distance of the inner bands from VWAP in volume-weighted standard deviations.")
float outerMult = input.float(2.0, "Outer band multiplier (σ)", minval = 0.2, step = 0.1, group = G_B, tooltip = "Distance of the outer bands from VWAP. Keep it larger than the inner multiplier.")
bool showVwap = input.bool(true, "Show VWAP line", group = G_B)
bool showU1 = input.bool(true, "Show upper band 1", group = G_B)
bool showU2 = input.bool(true, "Show upper band 2", group = G_B)
bool showL1 = input.bool(true, "Show lower band 1", group = G_B)
bool showL2 = input.bool(true, "Show lower band 2", group = G_B)
bool shadeInner = input.bool(true, "Shade inner regions (above / below VWAP)", group = G_B, tooltip = "Disabling shading does not disable any calculation.")
bool shadeOuter = input.bool(true, "Shade outer regions", group = G_B)
color vwapCol = input.color(color.new(#9E9E9E, 0), "VWAP color", group = G_B)
color upperCol = input.color(#FF7A66, "Upper band color (warm)", group = G_B)
color lowerCol = input.color(#1FE0B0, "Lower band color (cool)", group = G_B)
int vwapW = input.int(2, "VWAP line width", minval = 1, maxval = 6, group = G_B)
int bandW = input.int(1, "Band line width", minval = 1, maxval = 6, group = G_B)
// ── C — Anchored profile ────────────────────────────────────────────────────────────────────
bool showProfile = input.bool(true, "Show anchored volume profile", group = G_C)
int profRows = input.int(24, "Price rows", minval = 5, maxval = 100, group = G_C, tooltip = "Number of equal price intervals the anchor range is divided into.")
string profRange = input.string(PR_FULL, "Price-range restriction", options = [PR_FULL, PR_BANDS], group = G_C, tooltip = "Full anchor range = lowest low to highest high of the anchor. Outer deviation bands = profile limited to the outer bands (volume outside is not counted).")
int profWidth = input.int(35, "Maximum profile width (bars)", minval = 5, maxval = 100, group = G_C)
int profOffset = input.int(6, "Profile offset from last bar (bars)", minval = 1, maxval = 50, group = G_C, tooltip = "Increase if the profile is clipped; you may need free space on the right of the chart (drag the chart left).")
bool classify = input.bool(true, "Split volume by candle direction (estimate)", group = G_C, tooltip = "Colors each row's volume by positive-direction vs negative-direction candles. This is an approximation, not true aggressor-side volume.")
color upVolCol = input.color(color.new(#1FE0B0, 25), "Positive-direction volume color", group = G_C)
color dnVolCol = input.color(color.new(#FF2D12, 25), "Negative-direction volume color", group = G_C)
color totVolCol = input.color(color.new(#9E9E9E, 45), "Unclassified volume color", group = G_C)
// ── D — Anchor POC ──────────────────────────────────────────────────────────────────────────
bool showAPoc = input.bool(true, "Show Anchor POC", group = G_D)
color aPocCol = input.color(#000000, "Anchor POC color", group = G_D, tooltip = "Default black matches a light chart. Use a lighter color on dark themes.")
int aPocW = input.int(2, "Anchor POC width", minval = 1, maxval = 6, group = G_D)
string aPocStyleIn = input.string("Solid", "Anchor POC line style", options = ["Solid", "Dashed", "Dotted"], group = G_D)
bool showAPocLbl = input.bool(true, "Show Anchor POC label", group = G_D)
// ── E — Rolling POC ─────────────────────────────────────────────────────────────────────────
bool showRPoc = input.bool(true, "Show Rolling POC", group = G_E)
int rollLen = input.int(50, "Recent window (bars)", minval = 5, maxval = 500, group = G_E, tooltip = "Number of recent bars used by the rolling profile. The same number of bars means different elapsed time on each timeframe — tune it to your trading horizon.")
int rollRows = input.int(24, "Price rows", minval = 5, maxval = 100, group = G_E)
int rollSmooth = input.int(5, "Smoothing length (SMA)", minval = 1, maxval = 50, group = G_E, tooltip = "The plotted Rolling POC is an SMA of the raw highest-volume interval price. 1 = no smoothing.")
color rollUpCol = input.color(#1FE0B0, "Rolling POC color — price at/above it", group = G_E)
color rollDnCol = input.color(#FF2D12, "Rolling POC color — price below it", group = G_E)
int rollW = input.int(3, "Rolling POC line width", minval = 1, maxval = 8, group = G_E)
bool showRaw = input.bool(false, "Also show RAW (unsmoothed) rolling POC", group = G_E)
bool showRPocLbl = input.bool(true, "Show Rolling POC label", group = G_E)
// ── F — Directional volume ──────────────────────────────────────────────────────────────────
bool useDelta = input.bool(true, "Enable estimated directional delta", group = G_F, tooltip = "Estimate from CANDLE DIRECTION only. Not verified bid/ask delta and not proof of institutional order flow.")
int recentLen = input.int(40, "Recent delta window (bars)", minval = 2, maxval = 500, group = G_F)
int rvolLen = input.int(20, "Relative-volume baseline length", minval = 2, maxval = 200, group = G_F, tooltip = "Standard: number of preceding bars averaged (evaluated bar excluded). Time-of-day: number of previous sessions averaged.")
string rvolMode = input.string(RV_STD, "Relative-volume method", options = [RV_STD, RV_TOD], group = G_F, tooltip = "Time-of-day compares with the same exchange-time minute of previous sessions (intraday only, needs at least 3 samples).")
// ── G — Signals ─────────────────────────────────────────────────────────────────────────────
bool showBuy = input.bool(true, "Enable BUY signals", group = G_G)
bool showSell = input.bool(true, "Enable SELL signals", group = G_G)
string lblSizeIn = input.string("Medium", "Label size", options = ["Small", "Medium", "Large"], group = G_G)
color buyCol = input.color(#00E5A8, "BUY label color", group = G_G)
color buyTxtCol = input.color(#000000, "BUY text color", group = G_G)
color sellCol = input.color(#F5220A, "SELL label color", group = G_G)
color sellTxtCol = input.color(#FFFFFF, "SELL text color", group = G_G)
string sigMode = input.string(SM_CONF, "Signal confirmation mode", options = [SM_CONF, SM_PROV], group = G_G, tooltip = "Confirmed labels appear only after the candle closes. The preview option shows a temporary '(prov.)' label on the forming candle; it is NOT a confirmed signal and never triggers alerts.")
string sigSens = input.string(SS_STD, "Signal sensitivity", options = [SS_STD, SS_HIGH], group = G_G, tooltip = "Standard: crossover of close vs the SMOOTHED Rolling POC (the plotted line). High: crossover vs the RAW (unsmoothed) Rolling POC, which reacts faster and produces more BUY and SELL labels. The VWAP-side rule and confirmed-bar rule are identical in both.")
bool strictCross = input.bool(false, "Strict price-driven crossover", group = G_G, tooltip = "OFF (default, matches the brief): plain crossover/crossunder of close vs the POC series. ON: the previous close must also be on the other side of the CURRENT POC value, so a signal is never created only because the POC line itself jumped. ON gives fewer signals.")
bool lblPrice = input.bool(false, "Show close price inside label", group = G_G)
bool flashBg = input.bool(false, "Tint signal bar background", group = G_G, tooltip = "Adds a light background tint on bars that carry a confirmed BUY or SELL.")
int cooldownBars = input.int(0, "Cooldown (min bars between same-direction signals)", minval = 0, maxval = 500, group = G_G, tooltip = "0 = disabled (core rules unchanged). Higher values reduce signal frequency.")
bool useRvolFilter = input.bool(false, "Filter: require minimum relative volume", group = G_G, tooltip = "Optional. Reduces signal frequency. Does not imply direction.")
float rvolMin = input.float(1.0, "Minimum relative volume", minval = 0.1, step = 0.1, group = G_G)
// ── H — Dashboard ───────────────────────────────────────────────────────────────────────────
bool showDash = input.bool(true, "Show dashboard", group = G_H)
string dashPosIn = input.string("Top Right", "Position", options = ["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group = G_H)
string dashSizeIn = input.string("Small", "Text size", options = ["Tiny", "Small", "Normal", "Large"], group = G_H)
bool compactDash = input.bool(false, "Compact layout", group = G_H, tooltip = "Hides symbol/anchor info, nearest levels and last signal rows.")
string distUnit = input.string(DU_ATR, "Distance units", options = [DU_ATR, DU_ABS, DU_PCT, DU_TICK], group = G_H, tooltip = "Unit used for distance to reference levels. ATR uses the chart timeframe and the ATR length from Advanced Settings.")
bool rowSym = input.bool(true, "Row: symbol / timeframe / anchor", group = G_H)
bool rowDelta = input.bool(true, "Row: directional delta (anchor + recent)", group = G_H)
bool rowNear = input.bool(true, "Row: nearest levels above / below", group = G_H)
bool rowRvol = input.bool(true, "Row: relative volume", group = G_H)
bool rowLast = input.bool(true, "Row: last confirmed signal", group = G_H)
bool rowStatus = input.bool(true, "Row: calculation / data status", group = G_H)
color dashHdrBg = input.color(color.new(#E8EAED, 5), "Header background", group = G_H)
color dashBodyBg = input.color(color.new(#FFFFFF, 8), "Body background", group = G_H)
color dashTxtCol = input.color(#131722, "Text color", group = G_H)
color dashPosCol = input.color(#00A67E, "Positive value color", group = G_H)
color dashNegCol = input.color(#E02B1A, "Negative value color", group = G_H)
// ── I — Advanced ────────────────────────────────────────────────────────────────────────────
int atrLen = input.int(14, "ATR length (chart timeframe)", minval = 1, maxval = 200, group = G_I, tooltip = "Used for ATR-normalized distances.")
int profMaxBars = input.int(4000, "Max bars in anchored profile", minval = 100, maxval = 4900, group = G_I, tooltip = "Performance control. If an anchor holds more bars than this, only the most recent bars are profiled (the dashboard does not hide this).")
bool volFallback = input.bool(false, "Equal-weight fallback if feed has NO volume", group = G_I, tooltip = "Default OFF. If ON and the feed never supplies volume, VWAP uses equal weights (becomes an anchored average price) and the dashboard flags it. Profile/delta/relative volume stay unavailable.")
bool useHtf = input.bool(false, "HTF trend filter (BUY above HTF EMA, SELL below)", group = G_I, tooltip = "Optional, default OFF. Uses the previous COMPLETED higher-timeframe bar, so it adds up to one HTF bar of delay and lowers signal frequency.")
string htfIn = input.timeframe("60", "Higher timeframe", group = G_I, tooltip = "Must be equal to or higher than the chart timeframe.")
int htfEmaLen = input.int(50, "HTF EMA length", minval = 2, maxval = 400, group = G_I)
// ── J — Candle coloring ─────────────────────────────────────────────────────────────────────
bool candleOn = input.bool(false, "Color candles by distance from VWAP", group = G_J, tooltip = "Color shows closing-price distance from VWAP only. It does NOT mean the candle itself was bullish or bearish.")
color candleAboveCol = input.color(#FF7A66, "Above-VWAP color (strong)", group = G_J)
color candleBelowCol = input.color(#1FE0B0, "Below-VWAP color (strong)", group = G_J)
float candleInt = input.float(1.0, "Transition intensity", minval = 0.2, maxval = 3.0, step = 0.1, group = G_J, tooltip = "Higher = colors reach full strength at a smaller σ distance.")
// ═══════════════════════════════════════════════════════════════════════════════════════════
// HELPERS
// ═══════════════════════════════════════════════════════════════════════════════════════════
f_pos(string s) =>
switch s
"Top Left" => position.top_left
"Top Center" => position.top_center
"Top Right" => position.top_right
"Middle Left" => position.middle_left
"Middle Center" => position.middle_center
"Middle Right" => position.middle_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
=> position.bottom_right
f_tsize(string s) =>
switch s
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
=> size.large
f_lsize(string s) =>
switch s
"Small" => size.small
"Large" => size.large
=> size.normal
f_lstyle(string s) =>
switch s
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
=> line.style_solid
// Candle direction at offset i (uses built-in series only, so it is safe to call conditionally).
// +1 = positive candle, -1 = negative candle, 0 = neutral (doji with unchanged close).
f_dir(int i) =>
float c = close[i]
float o = open[i]
float pc = nz(close[i + 1], c)
int d = 0
if c > o
d := 1
else if c < o
d := -1
else if c > pc
d := 1
else if c < pc
d := -1
d
// Volume profile over the last n bars within [minP, maxP]. Fills upA / dnA (positive / negative
// direction volume per row) and returns [pocPrice, pocRowIndex]. Allocation: each candle's volume
// is spread over the rows overlapped by its [low, high] range, proportionally to the overlap.
f_profile(int n, int rows, float minP, float maxP, array<float> upA, array<float> dnA) =>
array.fill(upA, 0.0)
array.fill(dnA, 0.0)
float pocP = na
int pocI = -1
if n > 0 and rows > 0 and maxP > minP
float step = (maxP - minP) / rows
for i = 0 to n - 1
float v = nz(volume[i])
if v > 0
int d = f_dir(i)
float h = high[i]
float l = low[i]
float bl = math.max(l, minP)
float bh = math.min(h, maxP)
if h > l
if bh > bl
int b0 = math.min(rows - 1, int((bl - minP) / step))
int b1 = math.min(rows - 1, int((bh - minP) / step))
for b = b0 to b1
float segLo = math.max(bl, minP + b * step)
float segHi = math.min(bh, minP + (b + 1) * step)
float share = v * math.max(segHi - segLo, 0.0) / (h - l)
float upS = d > 0 ? share : d == 0 ? share * 0.5 : 0.0
float dnS = d < 0 ? share : d == 0 ? share * 0.5 : 0.0
array.set(upA, b, array.get(upA, b) + upS)
array.set(dnA, b, array.get(dnA, b) + dnS)
else if l >= minP and l <= maxP
int b = math.min(rows - 1, int((l - minP) / step))
float upS = d > 0 ? v : d == 0 ? v * 0.5 : 0.0
float dnS = d < 0 ? v : d == 0 ? v * 0.5 : 0.0
array.set(upA, b, array.get(upA, b) + upS)
array.set(dnA, b, array.get(dnA, b) + dnS)
float best = 0.0
for b = 0 to rows - 1
float t = array.get(upA, b) + array.get(dnA, b)
if t > best
best := t
pocI := b
if pocI >= 0
pocP := minP + (pocI + 0.5) * step
[pocP, pocI]
// ═══════════════════════════════════════════════════════════════════════════════════════════
// CORE SERIES
// ═══════════════════════════════════════════════════════════════════════════════════════════
float vol = nz(volume)
float cumVolAll = ta.cum(vol)
bool noVolFeed = cumVolAll <= 0
float wgt = vol > 0 ? vol : (volFallback and noVolFeed ? 1.0 : 0.0)
float atrVal = ta.atr(atrLen)
// ── Anchor detection ────────────────────────────────────────────────────────────────────────
bool chgW = timeframe.change("W")
bool chgM = timeframe.change("M")
bool chgQ = timeframe.change("3M")
bool chgY = timeframe.change("12M")
bool chgS = timeframe.isintraday ? session.isfirstbar : chgW
bool anchorChg = anchorIn == "Session" ? chgS : anchorIn == "Week" ? chgW : anchorIn == "Month" ? chgM : anchorIn == "Quarter" ? chgQ : chgY
bool anchorStart = bar_index == 0 or anchorChg
// ── Direction / directional volume ──────────────────────────────────────────────────────────
int dirNow = f_dir(0)
float upV = dirNow > 0 ? vol : 0.0
float dnV = dirNow < 0 ? vol : 0.0
// ── Anchored accumulators ───────────────────────────────────────────────────────────────────
var float cumW = 0.0
var float cumWP = 0.0
var float cumWP2 = 0.0
var float cumUp = 0.0
var float cumDn = 0.0
var int anchorBars = 0
var int anchorStartBar = 0
if anchorStart
cumW := 0.0
cumWP := 0.0
cumWP2 := 0.0
cumUp := 0.0
cumDn := 0.0
anchorBars := 0
anchorStartBar := bar_index
cumW += wgt
cumWP += wgt * srcIn
cumWP2 += wgt * srcIn * srcIn
cumUp += upV
cumDn += dnV
anchorBars += 1
// ── VWAP, dispersion, bands ─────────────────────────────────────────────────────────────────
float vwapV = cumW > 0 ? cumWP / cumW : na
float sdRaw = (anchorBars >= MIN_OBS and cumW > 0) ? math.sqrt(math.max(cumWP2 / cumW - vwapV * vwapV, 0.0)) : na
float sdV = (not na(sdRaw) and sdRaw > 0) ? sdRaw : na
float u1 = vwapV + innerMult * sdV
float u2 = vwapV + outerMult * sdV
float l1 = vwapV - innerMult * sdV
float l2 = vwapV - outerMult * sdV
float zV = (close - vwapV) / sdV
// ── Directional delta ───────────────────────────────────────────────────────────────────────
float anchTot = cumUp + cumDn
float anchDelta = (useDelta and anchTot > 0) ? (cumUp - cumDn) / anchTot * 100.0 : na
float recUp = math.sum(upV, recentLen)
float recDn = math.sum(dnV, recentLen)
float recTot = recUp + recDn
float recDelta = (useDelta and recTot > 0 and bar_index >= recentLen - 1) ? (recUp - recDn) / recTot * 100.0 : na
// ── Relative volume ─────────────────────────────────────────────────────────────────────────
type VolBucket
array<float> vals
var map<int, VolBucket> todMap = map.new<int, VolBucket>()
int todKey = hour * 60 + minute
float baseAvg = ta.sma(vol[1], rvolLen)
float rvolStd = (not na(baseAvg) and baseAvg > 0) ? vol / baseAvg : na
float todAvg = na
if timeframe.isintraday and rvolMode == RV_TOD
VolBucket bk = map.get(todMap, todKey)
if not na(bk)
if array.size(bk.vals) >= 3
todAvg := array.avg(bk.vals)
float rvolTod = (not na(todAvg) and todAvg > 0) ? vol / todAvg : na
if barstate.isconfirmed and timeframe.isintraday and rvolMode == RV_TOD
VolBucket bk2 = map.get(todMap, todKey)
if na(bk2)
bk2 := VolBucket.new(array.new_float())
map.put(todMap, todKey, bk2)
array.push(bk2.vals, vol)
if array.size(bk2.vals) > rvolLen
array.shift(bk2.vals)
bool useTod = rvolMode == RV_TOD and timeframe.isintraday
float rvolBar = useTod ? rvolTod : rvolStd
float rvolDone = barstate.isconfirmed ? rvolBar : rvolBar[1]
// ── Rolling POC ─────────────────────────────────────────────────────────────────────────────
var array<float> rUp = array.new_float(rollRows, 0.0)
var array<float> rDn = array.new_float(rollRows, 0.0)
float rMin = ta.lowest(low, rollLen)
float rMax = ta.highest(high, rollLen)
int nRoll = math.min(rollLen, bar_index + 1)
[rPocRaw, _rIdx] = f_profile(nRoll, rollRows, rMin, rMax, rUp, rDn)
float rPoc = ta.sma(rPocRaw, rollSmooth)
// ── HTF context (previous completed HTF bar only → no future data) ─────────────────────────
bool htfValid = timeframe.in_seconds(htfIn) >= timeframe.in_seconds(timeframe.period)
[htfC, htfE] = request.security(syminfo.tickerid, htfIn, [close[1], ta.ema(close, htfEmaLen)[1]], lookahead = barmerge.lookahead_on)
bool htfBuyOk = not useHtf or (htfValid and not na(htfC) and not na(htfE) and htfC > htfE)
bool htfSellOk = not useHtf or (htfValid and not na(htfC) and not na(htfE) and htfC < htfE)
// ═══════════════════════════════════════════════════════════════════════════════════════════
// SIGNALS
// ═══════════════════════════════════════════════════════════════════════════════════════════
float sigPoc = sigSens == SS_HIGH ? rPocRaw : rPoc
bool sigReady = not na(vwapV) and not na(sigPoc) and anchorBars >= MIN_OBS
bool rvolOk = not useRvolFilter or (not na(rvolBar) and rvolBar >= rvolMin)
bool crossUp = ta.crossover(close, sigPoc)
bool crossDn = ta.crossunder(close, sigPoc)
bool strictUp = not strictCross or close[1] <= sigPoc
bool strictDn = not strictCross or close[1] >= sigPoc
bool buyRaw = sigReady and crossUp and strictUp and close < vwapV and htfBuyOk and rvolOk
bool sellRaw = sigReady and crossDn and strictDn and close > vwapV and htfSellOk and rvolOk
var int lastBuyBar = na
var int lastSellBar = na
bool buyCool = cooldownBars == 0 or na(lastBuyBar) or bar_index - lastBuyBar >= cooldownBars
bool sellCool = cooldownBars == 0 or na(lastSellBar) or bar_index - lastSellBar >= cooldownBars
bool buySig = showBuy and buyRaw and buyCool and barstate.isconfirmed
bool sellSig = showSell and sellRaw and sellCool and barstate.isconfirmed
var string lastSigTxt = "None"
var int buyCount = 0
var int sellCount = 0
if buySig
lastBuyBar := bar_index
buyCount += 1
lastSigTxt := "BUY @ " + str.tostring(close, format.mintick) + " | " + str.format_time(time, "dd MMM HH:mm", syminfo.timezone)
if sellSig
lastSellBar := bar_index
sellCount += 1
lastSigTxt := "SELL @ " + str.tostring(close, format.mintick) + " | " + str.format_time(time, "dd MMM HH:mm", syminfo.timezone)
string lblSize = f_lsize(lblSizeIn)
string buyTxt = lblPrice ? "BUY\n" + str.tostring(close, format.mintick) : "BUY"
string sellTxt = lblPrice ? "SELL\n" + str.tostring(close, format.mintick) : "SELL"
string sigInfo = "\nσ from VWAP: " + (na(zV) ? "n/a" : str.tostring(zV, "0.00")) + "\nRel. volume: " + (na(rvolBar) ? "n/a" : str.tostring(rvolBar, "0.00") + "×") + "\nRecent delta (est.): " + (na(recDelta) ? "n/a" : str.tostring(recDelta, "0.0") + "%")
if buySig
label.new(bar_index, na, buyTxt, xloc = xloc.bar_index, yloc = yloc.belowbar, color = buyCol, style = label.style_label_up, textcolor = buyTxtCol, size = lblSize, tooltip = "AURIX FlowMatrix BUY (confirmed)\nClose: " + str.tostring(close, format.mintick) + "\nRolling POC: " + str.tostring(rPoc, format.mintick) + "\nVWAP: " + str.tostring(vwapV, format.mintick) + sigInfo)
if sellSig
label.new(bar_index, na, sellTxt, xloc = xloc.bar_index, yloc = yloc.abovebar, color = sellCol, style = label.style_label_down, textcolor = sellTxtCol, size = lblSize, tooltip = "AURIX FlowMatrix SELL (confirmed)\nClose: " + str.tostring(close, format.mintick) + "\nRolling POC: " + str.tostring(rPoc, format.mintick) + "\nVWAP: " + str.tostring(vwapV, format.mintick) + sigInfo)
// ── Alerts (conditions only; the user must still create the alert in TradingView) ──────────
alertcondition(buySig, title = "AURIX FlowMatrix BUY (confirmed)", message = "AURIX FlowMatrix | BUY | {{exchange}}:{{ticker}} | TF {{interval}} | Close {{close}} | Confirmed {{timenow}}")
alertcondition(sellSig, title = "AURIX FlowMatrix SELL (confirmed)", message = "AURIX FlowMatrix | SELL | {{exchange}}:{{ticker}} | TF {{interval}} | Close {{close}} | Confirmed {{timenow}}")
alertcondition(buySig or sellSig, title = "AURIX FlowMatrix BUY or SELL (confirmed)", message = "AURIX FlowMatrix | Confirmed signal | {{exchange}}:{{ticker}} | TF {{interval}} | Close {{close}} | Confirmed {{timenow}}")
bgcolor(flashBg and buySig ? color.new(buyCol, 85) : flashBg and sellSig ? color.new(sellCol, 85) : na, title = "Signal bar tint")
// ═══════════════════════════════════════════════════════════════════════════════════════════
// PLOTS
// ═══════════════════════════════════════════════════════════════════════════════════════════
pVwap = plot(vwapV, "VWAP", color = vwapCol, linewidth = vwapW, style = plot.style_linebr, display = showVwap ? display.all : display.none)
pU1 = plot(u1, "Upper band 1", color = color.new(upperCol, 45), linewidth = bandW, style = plot.style_linebr, display = showU1 ? display.all : display.none)
pU2 = plot(u2, "Upper band 2", color = color.new(upperCol, 25), linewidth = bandW, style = plot.style_linebr, display = showU2 ? display.all : display.none)
pL1 = plot(l1, "Lower band 1", color = color.new(lowerCol, 45), linewidth = bandW, style = plot.style_linebr, display = showL1 ? display.all : display.none)
pL2 = plot(l2, "Lower band 2", color = color.new(lowerCol, 25), linewidth = bandW, style = plot.style_linebr, display = showL2 ? display.all : display.none)
fill(pVwap, pU1, color = shadeInner ? color.new(upperCol, 92) : color(na), title = "Upper inner region")
fill(pVwap, pL1, color = shadeInner ? color.new(lowerCol, 90) : color(na), title = "Lower inner region")
fill(pU1, pU2, color = shadeOuter ? color.new(upperCol, 86) : color(na), title = "Upper outer region")
fill(pL1, pL2, color = shadeOuter ? color.new(lowerCol, 84) : color(na), title = "Lower outer region")
color rollColNow = close >= rPoc ? rollUpCol : rollDnCol
plot(rPoc, "Rolling POC", color = rollColNow, linewidth = rollW, style = plot.style_linebr, display = showRPoc ? display.all : display.none)
plot(rPocRaw, "Rolling POC (raw)", color = color.new(rollColNow, 40), linewidth = 1, style = plot.style_circles, display = showRaw ? display.all : display.none)
// Data-window-only values
plot(zV, "σ distance from VWAP", display = display.data_window)
plot(anchDelta, "Anchor delta % (est.)", display = display.data_window)
plot(recDelta, "Recent delta % (est.)", display = display.data_window)
plot(rvolDone, "Relative volume (closed bar)", display = display.data_window)
// ── Candle coloring ─────────────────────────────────────────────────────────────────────────
color candleCol = na
if candleOn and not na(zV)
float cap = math.max(outerMult, 0.1)
float tt = math.min(math.abs(zV) * candleInt, cap)
candleCol := zV >= 0 ? color.from_gradient(tt, 0, cap, color.new(candleAboveCol, 70), candleAboveCol) : color.from_gradient(tt, 0, cap, color.new(candleBelowCol, 70), candleBelowCol)
barcolor(candleCol, title = "AURIX FlowMatrix candle color")
// ═══════════════════════════════════════════════════════════════════════════════════════════
// LIVE DRAWINGS + DASHBOARD (computed for the latest bar only)
// ═══════════════════════════════════════════════════════════════════════════════════════════
var array<float> aUp = array.new_float(profRows, 0.0)
var array<float> aDn = array.new_float(profRows, 0.0)
var array<box> upBoxes = array.new<box>()
var array<box> dnBoxes = array.new<box>()
var box pocBox = na
var line aPocLine = na
var label aPocLbl = na
var label rPocLbl = na
var label legUp = na
var label legDn = na
var label provLbl = na
var table dash = table.new(f_pos(dashPosIn), 3, 16, bgcolor = dashBodyBg, frame_color = color.new(#9AA0A6, 40), frame_width = 1, border_color = color.new(#9AA0A6, 60), border_width = 1)
string dashSize = f_tsize(dashSizeIn)
f_px(float v) =>
na(v) ? "n/a" : str.tostring(v, format.mintick)
f_pct(float v) =>
na(v) ? "n/a" : (v >= 0 ? "+" : "-") + str.tostring(math.abs(v), "0.00") + "%"
f_fmt_dist(float d) =>
string r = "n/a"
if not na(d)
float a = math.abs(d)
if distUnit == DU_ABS
r := str.tostring(a, format.mintick)
else if distUnit == DU_PCT
r := close != 0 ? str.tostring(a / close * 100, "0.00") + "%" : "n/a"
else if distUnit == DU_TICK
r := syminfo.mintick > 0 ? str.tostring(a / syminfo.mintick, "#") + " ticks" : "n/a"
else
r := (not na(atrVal) and atrVal > 0) ? str.tostring(a / atrVal, "0.00") + " ATR" : "n/a"
r
f_side(float ref) =>
na(ref) ? "n/a" : (close > ref ? "Price above" : close < ref ? "Price below" : "Price at level") + " | " + f_fmt_dist(close - ref)
f_cell(int c, int r, string txt, color tc, color bg, string ha) =>
table.cell(dash, c, r, txt, text_color = tc, bgcolor = bg, text_size = dashSize, text_halign = ha)
f_row(int r, string a, string b, string c, color bc) =>
f_cell(0, r, a, dashTxtCol, dashBodyBg, text.align_left)
f_cell(1, r, b, bc, dashBodyBg, text.align_right)
f_cell(2, r, c, dashTxtCol, dashBodyBg, text.align_left)
if barstate.islast
// ── Anchored profile + Anchor POC ──────────────────────────────────────────────────────
float aPoc = na
float aMinP = na
float aMaxP = na
int aIdx = -1
int nA = math.min(anchorBars, profMaxBars)
bool aTrunc = anchorBars > profMaxBars
if nA > 0 and (not noVolFeed)
float mn = low
float mx = high
for i = 0 to nA - 1
mn := math.min(mn, low[i])
mx := math.max(mx, high[i])
if profRange == PR_BANDS and not na(u2) and not na(l2)
mn := l2
mx := u2
aMinP := mn
aMaxP := mx
[pocP, pocI] = f_profile(nA, profRows, mn, mx, aUp, aDn)
aPoc := pocP
aIdx := pocI
int xRight = bar_index + profOffset + profWidth
// Anchor POC line + label
if showAPoc and not na(aPoc)
int xStart = math.max(anchorStartBar, bar_index - 4900)
if na(aPocLine)
aPocLine := line.new(xStart, aPoc, xRight, aPoc, xloc = xloc.bar_index, color = aPocCol, width = aPocW, style = f_lstyle(aPocStyleIn))
else
line.set_xy1(aPocLine, xStart, aPoc)
line.set_xy2(aPocLine, xRight, aPoc)
if showAPocLbl
string t = "Anchor POC " + f_px(aPoc)
if na(aPocLbl)
aPocLbl := label.new(bar_index + 1, aPoc, t, xloc = xloc.bar_index, color = color.new(aPocCol, 100), textcolor = aPocCol, style = label.style_label_left, size = size.small)
else
label.set_xy(aPocLbl, bar_index + 1, aPoc)
label.set_text(aPocLbl, t)
else
if not na(aPocLine)
line.delete(aPocLine)
aPocLine := na
if not na(aPocLbl)
label.delete(aPocLbl)
aPocLbl := na
// Rolling POC label
if showRPoc and showRPocLbl and not na(rPoc)
string rt = "Rolling POC " + f_px(rPoc)
if na(rPocLbl)
rPocLbl := label.new(bar_index + 1, rPoc, rt, xloc = xloc.bar_index, color = color.new(rollColNow, 100), textcolor = rollColNow, style = label.style_label_left, size = size.small)
else
label.set_xy(rPocLbl, bar_index + 1, rPoc)
label.set_text(rPocLbl, rt)
label.set_textcolor(rPocLbl, rollColNow)
else
if not na(rPocLbl)
label.delete(rPocLbl)
rPocLbl := na
// Profile boxes
if showProfile and not na(aPoc)
if array.size(upBoxes) == 0
for b = 0 to profRows - 1
array.push(upBoxes, box.new(bar_index, 0.0, bar_index, 0.0, border_color = color(na), bgcolor = color(na), xloc = xloc.bar_index))
array.push(dnBoxes, box.new(bar_index, 0.0, bar_index, 0.0, border_color = color(na), bgcolor = color(na), xloc = xloc.bar_index))
pocBox := box.new(bar_index, 0.0, bar_index, 0.0, border_color = aPocCol, border_width = 1, bgcolor = color(na), xloc = xloc.bar_index)
float stepA = (aMaxP - aMinP) / profRows
float maxTot = 0.0
for b = 0 to profRows - 1
maxTot := math.max(maxTot, array.get(aUp, b) + array.get(aDn, b))
int x0 = bar_index + profOffset
for b = 0 to profRows - 1
float u = array.get(aUp, b)
float d = array.get(aDn, b)
float bot = aMinP + b * stepA
float top = bot + stepA
int wU = 0
int wD = 0
if maxTot > 0
if classify
wU := int(math.round(u / maxTot * profWidth))
wD := int(math.round(d / maxTot * profWidth))
else
wU := int(math.round((u + d) / maxTot * profWidth))
box bu = array.get(upBoxes, b)
box bd = array.get(dnBoxes, b)
box.set_lefttop(bu, x0, top)
box.set_rightbottom(bu, x0 + wU, bot)
box.set_bgcolor(bu, wU > 0 ? (classify ? upVolCol : totVolCol) : color(na))
box.set_lefttop(bd, x0 + wU, top)
box.set_rightbottom(bd, x0 + wU + wD, bot)
box.set_bgcolor(bd, wD > 0 ? dnVolCol : color(na))
if aIdx >= 0
box.set_lefttop(pocBox, x0, aMinP + (aIdx + 1) * stepA)
box.set_rightbottom(pocBox, x0 + profWidth, aMinP + aIdx * stepA)
box.set_border_color(pocBox, showAPoc ? aPocCol : color(na))
if classify
string t1 = "BUY VOLUME (est.)"
string t2 = "SELL VOLUME (est.)"
if na(legUp)
legUp := label.new(x0, aMinP - stepA * 1.2, t1, xloc = xloc.bar_index, color = color.new(upVolCol, 100), textcolor = color.new(upVolCol, 0), style = label.style_label_left, size = size.tiny)
legDn := label.new(x0, aMinP - stepA * 2.6, t2, xloc = xloc.bar_index, color = color.new(dnVolCol, 100), textcolor = color.new(dnVolCol, 0), style = label.style_label_left, size = size.tiny)
else
label.set_xy(legUp, x0, aMinP - stepA * 1.2)
label.set_xy(legDn, x0, aMinP - stepA * 2.6)
// ── Provisional preview (never a confirmed signal, never alerts) ───────────────────────
if not na(provLbl)
label.delete(provLbl)
provLbl := na
if sigMode == SM_PROV and not barstate.isconfirmed
if showBuy and buyRaw and buyCool
provLbl := label.new(bar_index, na, "BUY (prov.)", xloc = xloc.bar_index, yloc = yloc.belowbar, color = color.new(buyCol, 60), textcolor = buyTxtCol, style = label.style_label_up, size = lblSize, tooltip = "PROVISIONAL — candle not closed. May disappear.")
else if showSell and sellRaw and sellCool
provLbl := label.new(bar_index, na, "SELL (prov.)", xloc = xloc.bar_index, yloc = yloc.abovebar, color = color.new(sellCol, 60), textcolor = sellTxtCol, style = label.style_label_down, size = lblSize, tooltip = "PROVISIONAL — candle not closed. May disappear.")
// ── Dashboard ──────────────────────────────────────────────────────────────────────────
if showDash
// nearest references above / below price
array<float> refV = array.from(vwapV, u1, u2, l1, l2, aPoc, rPoc)
array<string> refN = array.from("VWAP", "Upper 1", "Upper 2", "Lower 1", "Lower 2", "Anchor POC", "Rolling POC")
float nAbove = na
float nBelow = na
string nAboveN = ""
string nBelowN = ""
for k = 0 to array.size(refV) - 1
float rv = array.get(refV, k)
if not na(rv)
if rv > close and (na(nAbove) or rv < nAbove)
nAbove := rv
nAboveN := array.get(refN, k)
if rv < close and (na(nBelow) or rv > nBelow)
nBelow := rv
nBelowN := array.get(refN, k)
bool tickProxy = syminfo.type == "forex" or syminfo.type == "cfd"
string stat = "OK"
string statDet = "All calculations available"
color statCol = dashPosCol
if noVolFeed and not volFallback
stat := "NO VOLUME"
statDet := "Feed has no volume: VWAP/profile/delta unavailable"
statCol := dashNegCol
else if noVolFeed and volFallback
stat := "LIMITED"
statDet := "Equal-weight fallback (no volume): VWAP only"
statCol := dashNegCol
else if anchorBars < MIN_OBS
stat := "WARM-UP"
statDet := "Anchor has too few bars"
statCol := dashTxtCol
else if na(rPoc)
stat := "WARM-UP"
statDet := "Rolling window not yet filled"
statCol := dashTxtCol
else if tickProxy
statDet := "OK | volume may be tick-based (proxy)"
if aTrunc and stat == "OK"
statDet := statDet + " | profile uses last " + str.tostring(profMaxBars) + " bars"
if useHtf and not htfValid
statDet := statDet + " | HTF must be >= chart TF"
string posTxt = na(vwapV) ? "n/a" : close > vwapV ? "Above VWAP" : close < vwapV ? "Below VWAP" : "At VWAP"
string sigTxt = na(zV) ? "σ n/a" : (zV >= 0 ? "+" : "-") + str.tostring(math.abs(zV), "0.00") + "σ from VWAP"
string rvTxt = na(rvolDone) ? "n/a" : str.tostring(rvolDone, "0.00") + "×"
string rvDet = (useTod ? "Time-of-day | " + str.tostring(rvolLen) + " sessions" : "Closed bar | " + str.tostring(rvolLen) + " avg")
// header
f_cell(0, 0, "AURIX FlowMatrix", dashTxtCol, dashHdrBg, text.align_left)
f_cell(1, 0, "VALUE", dashTxtCol, dashHdrBg, text.align_right)
f_cell(2, 0, "LIVE BAR", dashTxtCol, dashHdrBg, text.align_left)
int r = 1
if rowSym and not compactDash
f_row(r, "Symbol", syminfo.ticker, timeframe.period + " TF", dashTxtCol)
r += 1
f_row(r, "Anchor", anchorIn, str.tostring(anchorBars) + " bars", dashTxtCol)
r += 1
f_row(r, "Price", f_px(close), "Live", dashTxtCol)
r += 1
f_row(r, "VWAP position", posTxt, sigTxt, dashTxtCol)
r += 1
if not compactDash
f_row(r, "VWAP", f_px(vwapV), na(vwapV) ? "n/a" : f_fmt_dist(close - vwapV), dashTxtCol)
r += 1
f_row(r, "Anchor POC", f_px(aPoc), f_side(aPoc), dashTxtCol)
r += 1
f_row(r, "Rolling POC", f_px(rPoc), f_side(rPoc), dashTxtCol)
r += 1
if rowDelta
color ac = na(anchDelta) ? dashTxtCol : anchDelta > 0 ? dashPosCol : anchDelta < 0 ? dashNegCol : dashTxtCol
color rc = na(recDelta) ? dashTxtCol : recDelta > 0 ? dashPosCol : recDelta < 0 ? dashNegCol : dashTxtCol
f_row(r, "Anchor delta (est.)", f_pct(anchDelta), anchorIn + " | " + str.tostring(anchorBars) + " bars", ac)
r += 1
f_row(r, "Recent delta (est.)", f_pct(recDelta), str.tostring(recentLen) + " bars", rc)
r += 1
if rowNear and not compactDash
f_row(r, "Nearest above", f_px(nAbove), na(nAbove) ? "n/a" : nAboveN + " | " + f_fmt_dist(nAbove - close), dashTxtCol)
r += 1
f_row(r, "Nearest below", f_px(nBelow), na(nBelow) ? "n/a" : nBelowN + " | " + f_fmt_dist(close - nBelow), dashTxtCol)
r += 1
if rowRvol
f_row(r, "Relative volume", rvTxt, rvDet, dashTxtCol)
r += 1
if rowLast and not compactDash
f_row(r, "Signals B / S", str.tostring(buyCount) + " / " + str.tostring(sellCount), "Confirmed on loaded chart", dashTxtCol)
r += 1
f_row(r, "Last signal", "", lastSigTxt, dashTxtCol)
r += 1
if rowStatus
f_row(r, "Status", stat, statDet, statCol)
r += 1
// clear unused rows
while r < 16
f_cell(0, r, "", dashTxtCol, color(na), text.align_left)
f_cell(1, r, "", dashTxtCol, color(na), text.align_left)
f_cell(2, r, "", dashTxtCol, color(na), text.align_left)
r += 1