OPEN-SOURCE SCRIPT

Double Edge VP

2 941
🔷 Double Edge VP
━━━━━━━━━━━━━━━━━━━
Two institutional-grade tools. One indicator. Zero compromise.

This script brings together a dynamic Visible Range Volume Profile and a
non-repainting Double Bottom / Double Top pattern detector into a single
seamless overlay.

If you trade with volume context and price action structure together, this
is the only indicator you need on your chart.

─────────────────────────────────────────────────────────────
🔹 MODULE 1 — VISIBLE RANGE VOLUME PROFILE (VRVP)
─────────────────────────────────────────────────────────────

Most volume profiles are anchored to a fixed session or a manually selected
range. This one is different. The VRVP dynamically recalculates on every
incoming tick based on the exact bars currently visible on your screen.
Scroll left. Zoom in. Zoom out. The profile instantly rebuilds itself to
show the volume distribution for whatever price range you are looking at.

This is how professional traders use volume — not locked to a calendar
session, but alive and responsive to the context they are analyzing.

📌 Point of Control (POC)
The price row with the highest traded volume across the entire visible range.
This is the most accepted price level — the market's center of gravity.
Displayed as a bold golden dashed line spanning the full visible range with
a price label on the right edge. Price has a strong tendency to return to
the POC after extended moves away from it.

📌 Value Area — VAH & VAL
The zone containing 70% of all volume traded in the visible range (percentage
is fully adjustable). Based on the standard Auction Market Theory convention
used by professional futures and equity traders worldwide.

• Price trading inside the Value Area = fair value, expect rotation
• Price trading outside the Value Area = potential imbalance and opportunity

VAH and VAL are rendered as cyan dashed lines with a semi-transparent fill
between them, making the zone immediately readable at any zoom level.

📌 High Volume Nodes (HVN)
Rows where volume is at or above a configurable threshold relative to the POC
(default 75%). These are areas where the market spent significant time and
accepted price — they act as strong support and resistance levels. Price
frequently slows down, consolidates, or reverses at HVNs. Highlighted in teal.

📌 Low Volume Nodes (LVN)
Rows where volume is at or below a configurable threshold relative to the POC
(default 20%). These are price inefficiency zones — areas the market moved
through quickly with minimal acceptance. Price tends to travel rapidly through
LVNs in both directions and often returns to fill them later. Highlighted in red.

📌 Bull / Bear Volume Split
Every profile row is colored by directional dominance — green when buyer-
initiated volume exceeds seller-initiated, red when the opposite is true.
This gives you immediate insight into who controlled each price level, not
just how much volume traded there.

📌 Volume Labels Inside Every Bar
Each profile row displays its actual volume quantity directly inside the bar
itself — for example: 13.926K, 437, 2.8K. This is rendered using Pine
Script's box text parameter rather than label objects, which means every
single row is labeled regardless of Pine's 50-label hard cap. No rows are
ever skipped or silently dropped.

📌 Net Delta Box
The row with the largest absolute imbalance between buyer and seller volume
receives a standalone colored overlay showing the signed delta value —
for example -142 or +3.2K. Red background indicates net selling pressure.
Green background indicates net buying pressure. This single number tells
you where the market's sharpest directional commitment occurred.

─────────────────────────────────────────────────────────────
🔹 MODULE 2 — DOUBLE BOTTOM & DOUBLE TOP DETECTOR (DB/DT)
─────────────────────────────────────────────────────────────

Double Bottoms and Double Tops are among the most reliable reversal patterns
in technical analysis — but most detectors repaint, trigger too early, or
draw signals before the pattern is actually confirmed. This one does not.

Every signal in this detector is generated only after three conditions are
simultaneously true:

1. Two comparable pivot lows (or highs) have been confirmed with full
symmetric lookback on both sides — meaning the pivot cannot be detected
until the required number of bars has passed after it.

2. The price difference between the two pivots falls within your defined
tolerance threshold, ensuring genuine structural similarity.

3. The neckline has been broken by a configurable number of consecutive
bar closes in the signal direction — filtering out wicks, spikes, and
intra-bar noise that would otherwise produce false entries.

Once all three conditions are met, the signal is final and will never be
removed or moved to a different bar.

📌 Double Bottom — Bullish Reversal
Detects two pivot lows of similar price within a configurable bar window.
The neckline is automatically set to the highest high between the two bottoms.
A Long signal fires after the required number of consecutive closes above
the neckline. The indicator draws the "W" pattern connectors, DB labels at
both pivot points, a Long ↗ entry label, and the TP level line.

📌 Double Top — Bearish Reversal
Mirror logic of the Double Bottom. Two pivot highs of similar price within
the bar window. The neckline is the lowest low between the two tops. A Short
signal fires after consecutive closes below the neckline. Draws the "M"
pattern connectors, DT labels, a Short ↘ entry label, and the TP level line.

📌 7 TP / SL Calculation Modes
Choose the method that fits your trading style:

Bottom-to-Neckline → TP projected by the full pattern height (classic AMT)
R/R Ratio → Fixed reward-to-risk multiple, e.g. 2:1 or 3:1
ATR → Levels scaled dynamically by Average True Range
Percent → Fixed percentage distance from entry price
Points → Fixed point distance using syminfo.mintick
Pips → Fixed pip distance for forex instruments
Ticks → Fixed tick distance for futures instruments

📌 Trailing Stop Loss
When enabled, the stop loss moves in the direction of the trade as price
moves favorably, locking in profit while never widening risk. The trail
distance is fixed as the original entry-to-SL gap so your initial risk
profile is always preserved.

📌 TP Visual — Offset Dotted Line
The Take Profit level is displayed as a two-part line: a faint dotted
connector from the signal bar leading to a bold dotted TP segment that
begins a configurable number of bars to the right. This keeps the area
directly around the signal bar clean and readable — the same presentation
style used in institutional strategy publications.

─────────────────────────────────────────────────────────────
📊 LIVE STATISTICS TABLE
─────────────────────────────────────────────────────────────

A performance tracking table displays in your chosen screen position and
updates in real time as new patterns are detected across full chart history.

Tracked separately for Double Bottoms and Double Tops:

→ Total patterns detected
→ Trades triggered (neckline-confirmed signals only)
→ TP hits and SL hits (including trailing stop results)
→ Win rate % — color coded green above 50%, red below
→ Bar distance between pattern points: Min / Average / Median / Max
→ Price % difference between pattern points: Min / Average / Median / Max

Table position is fully configurable: Bottom Right, Bottom Left, Top Right,
Top Left, Middle Right, or Middle Left.

─────────────────────────────────────────────────────────────
🔔 ALERTS
─────────────────────────────────────────────────────────────

Two alert conditions fire on bar close — one for Long signals (Double Bottom
confirmed) and one for Short signals (Double Top confirmed).

Both messages are fully customizable and include the standard TradingView
dynamic placeholders {{ticker}}, {{interval}}, and {{close}} .

─────────────────────────────────────────────────────────────
⚙️ SETTINGS AT A GLANCE
─────────────────────────────────────────────────────────────

All inputs are organized into clearly labeled groups in the settings panel:

[VRVP] Profile → Rows, Value Area %, HVN threshold, LVN threshold
[VRVP] Visual → Profile width, POC / VA / fill / text / delta toggles
[VRVP] Colors → Full color control for every profile element

[DB/DT] Detection → Pivot length, bar range, % tolerance, confirm bars,
enable/disable DB and DT independently
[DB/DT] TP/SL → Mode selector, ATR settings, % / Points / Pips inputs,
trailing stop toggle, TP line offset and length
[DB/DT] Visual → Colors for dots, necklines, signals, pattern lines,
label size, dot size, show/hide toggles
[DB/DT] Table → Show/hide, position, text size
[DB/DT] Alerts → Custom long and short alert message text

─────────────────────────────────────────────────────────────
📐 TECHNICAL TRANSPARENCY
─────────────────────────────────────────────────────────────

• max_boxes_count = 500 | max_lines_count = 500 | max_labels_count = 500
• VRVP runs only on barstate.islast — profile boxes are cleared and rebuilt
every tick using pooled drawing arrays
• DB/DT runs every bar using individually named persistent var handles —
the two modules share zero drawing objects
• Volume labels use box.new(text=...) to bypass the 50-label hard cap
• All DB/DT signals are strictly non-repainting — confirmed on bar close only
• Trailing stop ratchets forward only, never widens, preserves original risk

─────────────────────────────────────────────────────────────
📌 RECOMMENDED USE
─────────────────────────────────────────────────────────────

This indicator is designed for traders who combine volume analysis with price
action structure. The VRVP provides the context — where volume was accepted,
where it was rejected, and what the market considers fair value right now.
The DB/DT detector provides the trigger — confirmed structural reversals at
levels where the volume profile gives you a reason to act.

Best suited for:
→ Liquid instruments with reliable volume data
(Equities, Futures, Crypto spot markets)
→ Intraday and swing timeframes (1m through Daily)
→ Traders familiar with Auction Market Theory
→ Traders who want pattern detection without repainting

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Use the VRVP to understand where the market has been.
Use the DB/DT detector to anticipate where it is going next.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Disclaimer: This indicator is for educational purposes only. Always practice proper risk management and combine with your own analysis before making trading decisions. Happy trading.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน