Isolated Scroll Container

1. Trend Pivots Profile Strategy Description

Draws a separate volume profile for each swing between two pivot reversal points, using intrabar volume pulled from a lower timeframe, plus a Donchian-channel-style trend line.

1.1 Indicator Concept

The indicator builds on the familiar Volume Profile idea (a sideways histogram showing which price area saw the most trading volume), but instead of drawing one fixed profile for a whole session/week, it automatically draws a separate profile for each up/down swing (between two consecutive pivot reversal points) and finds the Point of Control (PoC) — the price level with the most traded volume within that exact swing.

  • Why it needs lower-timeframe (LTF) data: the candle you see on your chart (e.g. 15-minute) only tells you the TOTAL volume for the whole candle, not which specific price within it attracted that volume. The indicator "dissects" each chart candle into smaller sub-candles/trades (e.g. 3-minute candles) to know exactly which price absorbed the most volume.
  • The Donchian-style trend line: alongside the profile logic, the indicator keeps a simple "currently in an up-phase or down-phase" state by tracking when price makes a fresh high/low within the last N bars — used both to color the profiles and to draw a reference trend line.

1.2 Indicator Features

  • Display:
    • Trend line: a thick, low-opacity line equal to the average of the highest high and lowest low over the last "Trend Length" bars (a Donchian channel midline) — always shown regardless of other settings.
    • Per-swing volume profile (when "Pivot Profile" is ON): every time a swing completes (confirmed by an opposite-type pivot), the indicator draws a sideways "bar chart" shape (a semi-transparent filled polyline) next to that swing, showing how much volume concentrated at each price area.
    • Reversal dot (●): a colored circle placed exactly at the just-confirmed pivot high/low.
    • PoC (Point of Control) line + label: a short horizontal line segment plus a volume-value label, placed exactly at the price level with the most volume in that swing.
    • Minimal mode (when "Pivot Profile" is OFF): hides all the drawings above and instead shows one continuous plotted line across the whole chart tracking the current PoC price — useful when you want the PoC as a normal data series (e.g. to reference from another indicator/strategy).
  • Alerts: The indicator has NO alertcondition() calls — it is purely visual.

1.3 How to Use the Indicator

  • Use the most recent swing's PoC as a potential support/resistance area: it's the price where the market traded the most during that specific swing, and the market tends to "remember" and react to it on a return visit.
  • Read the profile's shape (wide/narrow, skewed up/down) to judge whether that swing was "spread out" (little clear accumulation, easier to reverse through) or "heavily concentrated" in one area (a firmer support/resistance).
  • Watch the Trend line (Donchian channel) as a background trend reference, combined with the individual swing profiles to see which leg of the bigger trend you're currently in.
  • Keep "Pivot Profile" on for visual analysis, turn it off and use the plotted PoC line when you need to feed the PoC price into a calculation elsewhere.

1.4 How the Indicator Works

Inputs & their role

  • length ("Pivot Length", integer, default 10): serves three roles at once — the number of bars on each side needed to confirm a pivot high/low (so a pivot is only known "length" bars AFTER it actually formed), half the width of the window used to build each profile (the code always scans back length×2+1 bars around each pivot), and the maximum reach (in bars) that the "hottest" price level's profile bar can extend to the right.
  • trendLength ("Trend Length", integer, default 50): the lookback used for the recent highest-high/lowest-low (Donchian-style) — used both to draw the Trend line and to determine the current "up-phase or down-phase" state.
  • Profile ("Pivot Profile", on/off, default ON): switches between the full mode (colored volume-profile polyline + pivot dot + a separate colored PoC line/label) and the minimal mode (a single continuous plotted line following the PoC price, no polyline, no dot).
  • colorUp / colorDn (colors, defaults blue/orange): see the technical note — these two colors are NOT simply "uptrend"/"downtrend" in the intuitive sense; they key off which TYPE of pivot is currently anchoring the profile (a high or a low).

Main logic blocks

📈 Flow 1 — Donchian-style Trend State (every bar)

  • H = highest high, L = lowest low over the last trendLength bars; TrendLine = average (H+L)/2 — this is the always-drawn "Trend" line.
  • The state variable trend (persists across bars, changes only on a new event): flips to true the instant the current bar makes a fresh high within trendLength bars (high == H); flips to false the instant it makes a fresh low (low == L); otherwise keeps its previous value.

🔍 Flow 2 — Deciding When a Swing Is Complete Enough to Profile (every bar)

  • ph/pl = CONFIRMED pivot high/low (lagged by exactly "length" bars on each side).
  • The pivot flag: if trend is currently false (the most recent event was a fresh low) → wait for a newly confirmed HIGH pivot (ph) — this is the top of the up-swing that just finished before price turned down. If trend is currently true (the most recent event was a fresh high) → wait for a newly confirmed LOW pivot (pl) — the bottom of the down-swing that just finished.
  • Once pivot=true AND enough bars have passed since the last profile was drawn ((bar_index-length)-start > length) → a brand-new profile cycle begins, anchored exactly at the bar containing that pivot (start := bar_index-length).

📥 Flow 3 — Pulling Intrabar (LTF) Trade Data for the Whole Swing Window

  • The lower timeframe (LTF) is auto-selected from the current chart timeframe: chart ≤1 minute → use a 5-second LTF; otherwise → LTF = ceiling(chart minutes ÷ 5). Example: a 15-minute chart → LTF = ⌈15/5⌉ = 3 minutes; a 60-minute chart → LTF = ⌈60/5⌉ = 12 minutes.
  • Every chart bar remembers its own LTF close/volume data (via request.security_lower_tf). When a new profile cycle starts, the code "looks back" over the last length×2+1 bars (the exact window around the pivot) and re-reads the FULL LTF snapshot each of those bars saved, to aggregate them.

📊 Flow 4 — Building the Volume-at-Price Histogram

  • Price range [bottom, top] = lowest/highest price over that same length×2+1-bar window. Each "bin" (price bucket) width = atr = 10% of ATR(200) — fixed to overall volatility, not tied to the specific swing.
  • For EVERY recorded LTF trade in that window: its volume gets added into EVERY bin whose center falls within ±2×atr of that trade's close price (not just its single nearest bin) — see the technical note below on how this creates a "smoothed" profile with overlapping bins.
  • Concrete example: ATR(200)=20 → atr(bin width)=2.0. A swing spanning 24 price points → 12 bins, each 2.0 wide. An LTF trade closing at price X gets its volume added into EVERY bin whose center is within 4.0 points (±2 bins) of X — usually landing in 3-4 neighboring bins at once, not just one.

🎨 Flow 5 — Drawing the Profile Shape & Marking the PoC

  • Each bin becomes one point of a polyline, "reaching" rightward by an amount proportional to (that bin's volume ÷ the max bin's volume) × length — the highest-volume bin reaches the farthest (up to length bars); the very first and very last bins are always pinned back to the "start" column (no reach), so the shape closes into a sideways bar-chart silhouette.
  • The bin with the highest volume is marked as the PoC: a short line segment plus a formatted volume label (e.g. "1.2M") is drawn there.
  • If Profile is on: additionally draws the semi-transparent filled polyline plus a colored dot at the pivot point. If off: skips all of that, leaving only a continuous plot() line tracking the current PoC price across the whole chart.

🧹 Flow 6 — Cleaning Up Old Drawings (every bar)

  • Only the most recent 25 profile sets are kept on the chart; once a 26th is created, the OLDEST set (polyline + PoC line + PoC label + pivot dot) is permanently deleted — both to keep the chart from getting too cluttered and to stay within Pine's drawing-object limits (max_labels_count=500, max_lines_count=500, max_polylines_count=100, declared at the top of the code).

Outputs & how they're used

  • Trend line: a quick reference for which phase of the recent price channel you're in.
  • Per-swing volume profile + PoC: pinpoints the "hottest" price area of each swing, giving a volume-based support/resistance reference instead of relying on price shape alone.
  • Continuous plot mode (Profile off): lets you pull the PoC level as a normal data series to use elsewhere.
💡 Important technical notes:
  • The volume profile is NOT a strict, mutually-exclusive histogram: the tolerance for assigning volume to a bin is ±2×atr (2 full bin-widths) rather than ±0.5×atr (half a bin) as a normal histogram would use — meaning almost every trade ends up double-counted into 3-4 neighboring bins. As a result the profile's shape is significantly "smoothed" and does not accurately reflect the absolute volume proportion of any single price level.
  • colorUp/colorDn key off the TYPE of pivot currently anchoring the profile, not "trend is currently up/down": colorUp (blue by default) is used when trend is currently false — i.e. the code has just confirmed a HIGH pivot, marking an UP-swing that has just ended; colorDn (orange by default) is used when trend is currently true, having just confirmed a LOW pivot, marking a DOWN-swing that has just ended. The variable names easily suggest "colored by the current trend state", when they actually describe the DIRECTION of the swing that has just completed.
  • The "+15 bars" on the PoC line's creation is overwritten within the very same bar: when a new PoC line is created, it's set to extend to "start+right+15" — but immediately afterward, the line PoClevel.set_x2(bar_index+5) runs UNCONDITIONALLY at the end of every bar and overwrites that x2 value. The practical, on-chart result: the PoC line segment always appears to trail only 5 bars behind the current bar; the "+15" literal has essentially no visual effect.
Zoom/Pan Layered Image
Background Overlay
− +

The indicator above just became a TRADING BOT — 1 AI click

📊Original indicator
→
🤖AI 1-click convert
→
⚙️Bot trading 24/7