OPEN-SOURCE SCRIPT

BoaBias: Anchored Swing VWAP (MTF) - Touch, Alerts, Stats

624
█ WHAT IT DOES

Chart timeframe: Multiple anchored VWAP curves from swing pivots—not session VWAP. Resistance-anchored paths (swing highs) and support-anchored paths (swing lows) draw as polylines and clear after confirmation (same rules as the inputs: one qualifying close or N bars in a row). Optional touch markers when the bar range spans VWAP (green below / red above).

Higher timeframes: Optional HTF 1–3 reuse the same pivot + anchored-VWAP logic inside request.security with barmerge.gaps_off and barmerge.lookahead_off. Display as a ribbon (midline ± % of price) or stepped lines. Up to five concurrent VWAP slots per HTF (plot budget).

Alerts: Separate alert() channels—chart VWAP touches and optional HTF 1–3 midline touches when the chart bar’s range crosses the HTF VWAP. Prefixes: Chart VWAP touch / HTF VWAP touch with ticker, price, time, and touched lines on HTF. Create Alert → this script → Any alert() function call. Alert frequency input applies to every alert() from this script (once per bar / once per bar close / all ticks).

Reaction statistics (optional table): A compact on-chart table aggregates how closed swing-anchored lines behaved on the chart timeframe only—not HTF curves. Toggle in inputs; Show stats table is on in factory defaults for this build (disable to reduce on-chart load). Cohort splits include touched vs no-touch, K/M-style breakout vs bounce windows after first touch, ATR pierce vs hold, and simple marginal “first event” proxies (swing-side pivot, opposite-side VWAP range touch, close beyond last swing). Numbers are descriptive context, not trade signals or guaranteed forward behaviour. When the table is enabled, lifecycle logic shares a small Pine library module (BoaBiasVwapSwingRxStats) so stats stay aligned with line confirmation.

█ REACTION STATS TABLE — WHAT EACH ROW MEANS

Percent row labels use short tags: b = “b” bucket, br = “br” (break) bucket in the K/M and ATR rules defined in code (not a broker term). Counts and % are descriptive on history—not forecasts.

  • Row 0 (headers) — TF / Support / Resistance / All: TF shows the chart’s period. Columns 1–2 are support- and resistance-anchored closed lines. All = mixed view for FE totals and the combined line count.
  • Line 1 — n= and X lines: Support / Resistance show how many touched lines of that type finished (had at least one bar with range spanning VWAP before the line was confirmed and removed). The All cell shows the total completed lines: support + resistance anchors that were cleared by confirmation, including no-touch cases.
  • No-touch row: For lines that never had low ≤ VWAP ≤ high before the line was confirmed, split by S/R. Percent (where shown) = no-touch count ÷ all completed lines of that side (touched + no-touch).
  • K/M b% and K/M br%: Denominator = touched S/R lines only. After the first touch, the script tracks consecutive closes on the break side of VWAP (K bars) in a post-touch window, and a flag if that ever reaches K (see inputs). A line is bucketed as K/M br (break) if, at the confirmation bar, either: (1) the bar is still within M bars after the first touch, or (2) the K-hold was reached in the tracked window. Otherwise, among touched lines, it counts in K/M b (b = non-`br` in this K/M sense). The All cell on the K/M rows shows the active K/M from inputs.
  • ATR b% and ATR br%: Denominator = touched S/R. Uses ATR = R×ATR from VWAP (R and ATR length from inputs). A line is ATR br if, with touch, the confirmation bar is still within M_atr bars after the first touch or a pierce of that ATR band occurred in the tracked window. Otherwise the touched line is counted in ATR b. The All cell shows ATR length / R / M_atr used for the rule.
  • FE (marginal) rows — P(≥1), P(swing), P(opp), P(cls), P(none): Only for touched lines: before confirmation, the script can record the first bar of three optional “events” if they occur. P(≥1): % where at least one event occurred. P(swing): a pivot of the favourable side (for a resistance-anchored line, a swing low bar is relevant; for support, a swing high) is present in the path and used for the timing flag. P(opp): the range first crosses another active line of the opposite type (its VWAP in range). P(cls): close beyond the last recorded swing high (for support) or low (for resistance) before confirm. P(none): % where none of the three event types fired before the line closed. The All column pools S+R for the FE P(*) All percentages.
  • Avg life row: Average number of chart bars from the anchor to confirmation, over all completed lines. One merged cell in the table shows the value.




█ HOW IT WORKS

  • Pivots: ta.pivothigh / ta.pivotlow with configurable left/right length. Each anchor seeds cumulative typical-price × volume from the anchor forward; VWAP = cumulative TPV / cumulative volume along that line’s active segment.
  • Touch: low ≤ VWAP ≤ high on an active curve.
  • Confirmation: Line removal when closes satisfy the far-side rule after the minimum post-anchor bars—One bar or N bars in a row, per inputs.
  • HTF packaging: Same mechanics on selected higher TFs; values are pulled without lookahead from the security call.
  • Stats path: When the stats table is on, the script runs the shared library helpers so counters and polylines use the same confirmation and touch definitions as the visual path; HTF series do not feed those counters.



█ WHY THESE PIECES TOGETHER

Swing-anchored VWAP gives a volume path from structure; MTF ribbons or lines place that structure on a second axis of time; touch markers and alerts flag range overlap without claiming execution edges; optional stats summarize historical line outcomes for research. The bundle is one overlay for context and notification—not a black-box signal service.

█ HOW TO USE

  • First use: If the indicator appears in the wrong scale (squashed or fullscreen), right-click the indicator → Pin to scale → Pin to right scale.
  • Tune pivot length and confirmation mode; enable or disable touch markers, HTF layers, and each alert channel.
  • Add alert → this script → Any alert() function call; respect HTF toggles and that HTF alerts need the HTF layer shown and a higher TF than the chart.
  • Higher-timeframe VWAPs: Show HTF 1–3 on the same chart to reduce time and clicks switching TFs. The higher-TF midlines/ribbons add structural context (where swing-based volume paths sit) without leaving the current timeframe.
  • Reaction stats: The optional table is on by default; turn it off if the on-chart table or extra compute is not needed. It aggregates how past closed chart-TF lines behaved (cohort splits, not a live edge claim). That helps reason about relative bounce/break and related counts on history—useful for testing hypotheses and ideas (what-if inputs, not guaranteed forward odds).
  • As a set: HTF + chart VWAP + optional stats supports exploring a wide range of VWAP interaction ideas on the same price history. Position it as a research and strategy-development layer (iterate rules on the chart, risk management stays separate)—not a turnkey signal.


█ LIMITATIONS

Meaningful volume improves the curves. Five HTF VWAP slots max per HTF (plot cap). HTF alerts use the midline VWAP, not ribbon edges. Stats are chart-TF only and historical. Structural / educational tool—not financial advice and not a substitute for independent risk management.

免責聲明

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