OPEN-SOURCE SCRIPT
アップデート済

Pulse Trend Radar [WillyAlgoTrader]

39 922
⦿ Pulse Trend Radar is an overlay indicator built on a Kaufman Adaptive Moving Average (KAMA) core with median-ATR volatility bands — producing an adaptive trend system that speeds up in trending markets and slows down in noise. Every trend flip generates a signal scored by a 4-factor quality engine (0–100) with letter grades (A+ through C). The indicator also detects and visualizes liquidity zones from pivot highs/lows, marks order blocks from the last opposite candle before each trend flip, tracks real-time P&L with a live trade tracker, and monitors win/loss outcomes — creating a complete trend-following framework with Smart Money context.


🧩 WHY THESE COMPONENTS WORK TOGETHER

A trend indicator alone tells you direction — but not whether the entry is near a liquidity pool (where stops cluster), not whether there's institutional supply/demand nearby (order blocks), not how strong the signal is (all flips treated equally), and not how the system performs over time (no feedback).

This indicator layers four analysis dimensions onto the adaptive trend core:

KAMA adaptive trend + median ATR bands → Trend direction and flip detection
Liquidity zones from pivots → Where stop-hunts and liquidity grabs are likely
Order blocks from pre-flip candles → Where institutional supply/demand was established
4-factor signal scoring → Quality filtering — not all flips are equal
Win/loss tracker → Performance feedback on this instrument and timeframe

The KAMA core adapts its speed via the Efficiency Ratio — in a strong trend, the MA tracks price closely and the bands tighten, producing early signals. In choppy conditions, the MA barely moves and the bands widen, filtering out noise. The liquidity zones show where clusters of stops sit (above pivot highs, below pivot lows) — entries near these zones have higher follow-through because the liquidity grab fuels the move. The order blocks mark the institutional footprint before each trend change — these zones often act as support/resistance on retests. And the signal score combines trend strength, volume delta, efficiency acceleration, and liquidity proximity into a single quality metric — letting you prioritize A+ setups over C-grade ones.


🔍 WHAT MAKES IT ORIGINAL

1️⃣ Kaufman Adaptive Moving Average (KAMA) trend core.
The KAMA computes a smoothing constant from the Efficiency Ratio:

ER = |price − price[N]| / sum(|price − price[1]|, N)
fastSc = 2 / (fastLen + 1), slowSc = 2 / (slowLen + 1)
sc = (ER × (fastSc − slowSc) + slowSc)²
KAMA = KAMA[1] + sc × (price − KAMA[1])

When ER → 1 (pure trend): sc approaches fastSc² → KAMA tracks price tightly. When ER → 0 (pure noise): sc approaches slowSc² → KAMA barely moves. This produces a line that accelerates into trends and goes flat in chop — without any manual period switching.

2️⃣ Median ATR volatility bands.
Instead of standard ATR (arithmetic mean of true ranges), the indicator uses a median of recent true ranges computed via a ring buffer over the volatility lookback (default 50 bars). The median is more robust to outlier spikes (gap bars, flash wicks) than the mean — producing smoother, more stable band widths.

Bands: upper = KAMA + medianATR × multiplier, lower = KAMA − medianATR × multiplier. Trend flips when the previous bar's source price crosses beyond a band: source > upper → bullish, source < lower → bearish. The active band (lower in uptrend, upper in downtrend) is plotted as the trend line.

3️⃣ Displacement-based gradient fill.
The fill between the trend line and price is not a fixed transparency — it scales with displacement: displacement = |price − KAMA| / (medianATR × multiplier). The further price stretches from KAMA, the more intense the fill becomes (transparency decreases from 95 to 60). This creates a visual "heat map" effect: faint fill near KAMA (low extension), bright fill far from KAMA (overbought/oversold). This gives immediate visual feedback on how extended the current move is without needing a separate oscillator.

4️⃣ Liquidity zone detection and sweep tracking.
Pivot highs and lows (configurable lookback, default 4 bars) are marked as liquidity zones:
— Above pivot highs → bearish liquidity (buy stops cluster above swing highs — potential sell-side liquidity)
— Below pivot lows → bullish liquidity (sell stops cluster below swing lows — potential buy-side liquidity)

Each zone extends rightward as a thin box (height = 0.15× medianATR). Zones are automatically removed when price sweeps through them (high crosses above bearish zone top, or low crosses below bullish zone bottom) — representing the liquidity grab event. Up to 15 zones per side (configurable).

The signal scoring engine measures the nearest liquidity zone distance on each trend flip — entries closer to a liquidity pool receive a higher quality score because the stop-hunt provides fuel for the ensuing move.

5️⃣ Order block detection on trend flips.
When the trend flips, the previous bar is marked as an order block:
— Bullish flip → demand order block (the last bearish candle before the reversal — where institutional buying absorbed selling pressure)
— Bearish flip → supply order block (the last bullish candle before the drop — where institutions distributed)

Each OB is drawn as a box from the previous candle's high to low, extending rightward. OBs are automatically invalidated (deleted) when price closes beyond the opposite edge after 3+ bars — indicating the zone has been broken. Up to 10 OBs per side (configurable).

6️⃣ 4-factor signal quality scoring (0–100).
Each trend flip is scored on four factors:

— 📐 Trend strength (25 pts): combined from ER (directional efficiency) and displacement from KAMA — measures how strong the trend is at the moment of the flip
— 📊 Volume delta alignment (25 pts): buy volume vs sell volume accumulated during the previous trend leg — bullish flip with positive volume delta scores higher (smart money was accumulating)
— ⚡ Efficiency acceleration (25 pts): current ER minus previous ER — positive acceleration means the trend is gaining momentum, not losing it
— 💧 Liquidity proximity (25 pts): distance to the nearest liquidity zone — closer = higher score (the flip is near a liquidity grab point)

Grades: A+ (≥ 80), A (≥ 60), B (≥ 40), C (< 40). Signal labels display "Long A+" / "Short B" etc.

7️⃣ OBV-based volume regime detection.
On Balance Volume (OBV) delta = OBV − SMA(OBV, 20). Classified as:
— Accumulation: OBV delta > 0 — more volume on up-moves than down-moves (institutional buying)
— Distribution: OBV delta < 0 — more volume on down-moves (institutional selling)

Displayed in the dashboard with directional coloring. Auto-displays "N/A" on instruments without volume data.

8️⃣ Live trade tracker with P&L.
On each signal: a dashed entry line extends horizontally, a vertical connector line tracks from entry to current price, and a P&L label updates in real-time showing percentage gain/loss. Green = profit, red = loss. Replaced on each new signal.

9️⃣ Win/loss markers + win rate tracking.
Each signal is tracked as a mini-trade: entry at signal close, SL at entry ± medianATR × SL multiplier, TP1 at entry ± risk × TP1 multiplier. If TP1 is reached before SL → green ● marker at the signal bar (win). If SL is reached first → red ● marker (loss). Running win rate displayed in the dashboard as "67% (4W/2L)".

🔟 ATR-based TP/SL with hit tracking.
Three take-profit levels as risk multiples (default 1.0/2.0/3.0 × risk) plus SL (default 3× medianATR from entry). Lines extend rightward with labels showing price + percentage. Labels update with ✓ on hit (green) or ✗ on SL hit (red). Active until the next signal replaces them.


⚙️ HOW IT WORKS — CALCULATION FLOW

Step 1 — KAMA: Efficiency Ratio from configurable lookback → adaptive smoothing constant → KAMA line that accelerates in trends, goes flat in chop.

Step 2 — Median ATR bands: True ranges stored in ring buffer → median computed → upper/lower bands = KAMA ± median × multiplier.

Step 3 — Trend detection: Previous bar's source > upper band → bullish flip. Source < lower band → bearish flip. Active band plotted as trend line. Gradient fill scales with displacement.

Step 4 — Liquidity zones: Pivot highs/lows → boxes above/below. Swept zones auto-deleted.

Step 5 — Order blocks: On flip → previous candle becomes OB. Invalidated when price closes beyond opposite edge.

Step 6 — Signal scoring: 4 factors (trend strength, volume delta, ER acceleration, liquidity proximity) → 0–100 → A+/A/B/C grade.

Step 7 — Trade tracking: SL/TP placed, lines extend, win/loss evaluated per trade.


📖 HOW TO USE

🎯 Quick start:
1. Add the indicator — adaptive trend line, liquidity zones, and order blocks appear
2. "Long A+" / "Short B" labels = trend flip signals with quality grade
3. Green/red liquidity zone boxes = where stops cluster (potential sweep targets)
4. Green/red order blocks = institutional supply/demand zones
5. SL/TP lines auto-appear with P&L tracker

👁️ Reading the chart:
— 🟢 Green trend line = bullish (lower band active)
— 🔴 Red trend line = bearish (upper band active)
— 🟢/🔴 Gradient fill = displacement from KAMA (brighter = more extended)
— 🟢 Small boxes below price = bullish liquidity zones (buy-side stops)
— 🔴 Small boxes above price = bearish liquidity zones (sell-side stops)
— 🟢 Larger boxes = demand order blocks (institutional buying zone)
— 🔴 Larger boxes = supply order blocks (institutional selling zone)
— 🟢 ● = win (TP1 reached), 🔴 ● = loss (SL hit)
— Dashed line + PnL label = live trade tracker

📊 Dashboard fields:
— Trend: ▲ Bullish / ▼ Bearish
— Last Signal: BUY/SELL with grade [A+/A/B/C]
— Score: 0–100 quality rating
— Strength: trend strength percentage
— P&L: current trade percentage
— Win Rate: wins/losses with percentages
— SL / TP1: current trade levels with ✓/✗ status
— Vol Regime: Accumulation / Distribution
— Vol Delta: buy vs sell volume percentage
— Efficiency: current ER percentage

🔧 Tuning guide:
— Too many signals: increase Band Multiplier (2.0–2.5) or ER Length (15–20)
— Too few signals: decrease Band Multiplier (1.2–1.5) or ER Length (8–10)
— Signals too late: decrease Slow Smoothing (15–20), decrease Volatility Length (20–30)
— Stops too tight: increase SL ATR Multiplier (2.5–4.0)
— Want only A+/A signals: monitor grades in dashboard, skip B/C entries


⚙️ KEY SETTINGS REFERENCE

⚙️ Main:
— Efficiency Ratio Length (default 13): KAMA lookback — higher = smoother
— Fast/Slow Smoothing (default 2/30): KAMA acceleration/deceleration
— Band Multiplier (default 1.8): band width in median ATR
— Volatility Length (default 50): median ATR ring buffer size

🎯 SL/TP:
— SL (× ATR) (default 3): stop distance in median ATR
— TP1/TP2/TP3 (× risk) (default 1.0/2.0/3.0): R:R multiples

💧 Liquidity:
— Pivot Lookback (default 4) / Max Zones (default 15)

🟧 Order Blocks:
— Max Order Blocks (default 10)

🎨 Visual:
— Gradient fill, trade tracker, win/loss markers (all toggleable)
— Configurable signal label size (Tiny–Large)
— Configurable dashboard font size (Tiny–Normal)
— Auto / Dark / Light theme


🔔 Alerts

— 🟢 BUY [grade] / 🔴 SELL [grade] — ticker, price, TF, SL, TP1, TP3
All support plain text and JSON webhook format. Bar-close confirmed.


⚠️ IMPORTANT NOTES

— 🚫 No repainting. All signals require barstate.isconfirmed. Trend flips use the previous bar's source vs the previous bar's band value — the signal fires on the bar after the crossing bar closes. KAMA and band values are deterministic once a bar is confirmed.
— 📐 The median ATR is more robust than standard ATR. A single flash wick or gap bar shifts the mean (standard ATR) significantly but barely affects the median. This produces more stable band widths and fewer false flips during anomalous bars.
— 📊 Volume delta is accumulated within each trend leg and resets on every trend flip. It represents the buy/sell balance during the specific move — not the overall volume profile. The pre-reset delta value is used for the signal score (capturing the exiting leg's character).
— 💧 Liquidity zones are automatically swept and removed when price touches them. This prevents stale zones from cluttering the chart. If a zone disappears, it means price swept through it — the liquidity has been taken.
— 🟧 Order blocks are invalidated after 3+ bars if price closes beyond the opposite edge. This prevents old OBs that have clearly failed from persisting.
— ⚖️ The 4-factor score uses the volume delta from before the trend reset (preResetVolDelta) — not the current leg's delta, which would be zero at the moment of the flip. This correctly captures whether the previous leg had accumulation or distribution behind it.
— 📏 Win/loss tracking evaluates TP1 vs SL only — if TP1 is reached before SL, it's a win. The trade closes on the first event and is not re-evaluated.
— 🛠️ This is a trend-following signal and analysis tool, not an automated trading bot. It provides adaptive trend detection, liquidity context, order block zones, and signal quality grading — trade decisions remain yours.
— 🌐 Works on all markets and timeframes. Volume features auto-adapt to instruments without volume data (OBV and volume delta show "N/A").
リリースノート
🚀 v3.3.1 — Range Filter, Honest Statistics & Full Logic Audit

This is a major update focused on two things: filtering out choppy markets and making every number the indicator shows you honest and internally consistent.

⸻

⏸️ NEW — Range (Flat) Filter
- 📉 Detects ranging markets using the smoothed Kaufman Efficiency Ratio with hysteresis (separate ON/OFF thresholds prevent regime flicker)
- 🔇 While the market is ranging: trend-flip signals, alerts and SL/TP placement are suppressed, the trend line turns neutral, and an optional background shade marks the range
- 🔄 Resume signals: if the trend flipped while the market was flat, the signal fires when the range ends (marked "·R" in the dashboard) — trends that start inside a range are no longer missed. Can be disabled
- 🔔 Optional Range ON/OFF alerts, webhook JSON supported
- ⚙️ With the filter disabled, signal behavior matches the previous version exactly

⸻

📊 CHANGED — Win-Rate Statistics Are Honest Now
- ✅ Trades interrupted by an opposite signal are closed at the flip price and counted (profit = win, loss = loss) instead of being silently dropped
- 🏷️ Dashboard row renamed to "Win Rate (est.)" with a tooltip explaining exactly what it measures: the TP1-before-SL / flip-outcome rate at your configured R:R. It ignores fees and slippage and is NOT a measure of full-strategy performance
- ⚖️ SL is now checked before the TPs on every bar, consistently in both label tracking and statistics. Previously, a bar touching both a TP and the SL could show a ✓ TP label while the tracker counted a loss
- 🛑 Once SL is hit, the trade is treated as closed — TP levels reached afterwards are no longer marked ✓

⸻

🛠️ FIXED
- 🔗 Alerts no longer produce invalid webhook JSON ("sl":NaN) when "Show SL/TP Levels" is turned off — SL/TP prices are always calculated; the toggle controls drawing only
- 🎯 SL/TP hit tracking no longer depends on the Trade Tracker toggle (long-side hit detection could fail with the tracker disabled)
- 🟧 Order Blocks now actually search back (configurable depth, default 10 bars) for the last opposite-direction candle before a trend flip, as the description always claimed — previously the previous bar was taken regardless of its direction
- 📏 Entry marker lines are pooled and pruned so they can no longer crowd out SL/TP lines on long histories
- 📦 Liquidity and Order Block boxes no longer visually shrink one bar after creation

⸻

⚡ IMPROVED
- 🧮 Signal score recalibrated: the ER-momentum factor was effectively inactive at its old scale and now contributes meaningfully. Grades may shift slightly compared to previous versions. As always, the score is a heuristic ranking of signals relative to each other — not a calibrated probability of success
- ♻️ Efficiency Ratio is computed once and shared across KAMA, trend strength, scoring and the range filter (previously computed twice)
- 💾 Reduced memory footprint (max_bars_back lowered to match the actual lookback)
- 📋 Dashboard: Trend row shows "◆ Range" during flat periods with the live smoothed ER in the tooltip; Efficiency row tooltip shows the smoothed value used by the filter

⸻

🆕 New settings group: ⏸️ Range Filter — enable/disable, ON/OFF ER thresholds, ER smoothing, resume signals, background shading, regime alerts

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。