PROTECTED SOURCE SCRIPT

Adaptive HMA Trendfilter & Profit Spikes

15
Short Description

Adaptive trend-following filter using Hull Moving Average (HMA) slope.
Includes optional Keltner Channel entries/exits and dynamic spike-based take-profit markers (ATR/Z-Score).
Optional Fast HMA for early entry visualization (not included in logic).

USER GUIDE:

1) Quick Overview

Trend Filter: Slow HMA defines Bull / Bear / Sideways (via slope & direction).

Entries / Exits:

Entry: Color change of the slow HMA (red→green = Long, green→red = Short), optionally filtered by the Keltner basis.

Exit: Preferably via Keltner Band (Long: Close under Upper Band; Short: Close above Lower Band).
Fallback: exit on opposite HMA color change.

Take-Profit Spikes: Marks abnormal moves (ATR, Z-Score, or both) as discretionary TP signals.

Fast HMA (optional): Purely visual for early entry opportunities; not part of the core trading logic (see §5).

2) Adding & Basic Setup

Add the indicator to your chart.

Open Settings (gear icon) and configure:

HMA: Slow HMA Length = 55, Slope Lookback = 10, Slope Threshold = 0.20%.

Keltner: KC Length = 20, Multiplier = 1.5.

Spike-TP: Mode = ATR+Z, ATR Length = 14, Z Length = 20, Cooldown = 5.

Optionally: enable Fast HMA (e.g., length = 20).

3) Input Parameters – Key Controls

Slow HMA Length: Higher = smoother, fewer but cleaner signals.

Slope Lookback: How far back HMA slope is compared against.

Slope Threshold (%): Minimum slope to avoid “Sideways” regime.

KC Length / Multiplier: Width and reactivity of Keltner Channels.

Exits via KC Bands: Toggle on/off (recommended: on).

Entries only above/below KC Basis: Helps filter out chop.

Spike Mode: Choose ATR, Z, or ATR+Z (stricter, fewer signals).

Spikes only when in position: TP markers show only when you’re in a trade.

4) Entry & Exit Logic
Entries

Long: Slow HMA turns from red → green, and (if filter enabled) Close > KC Basis.

Short: Slow HMA turns from green → red, and (if filter enabled) Close < KC Basis.

Exits

KC Exit (recommended):

Long → crossunder(close, Upper KC) closes trade.

Short → crossover(close, Lower KC).

Fallback Exit: If KC Exits are off → exit on opposite HMA color change.

Spike-TP (Discretionary)

Marks unusually large deviations from HMA.

Use for partial profits or tightening stops.

⚠️ Not auto-traded — only marker/alert.

5) Early Entry Opportunities (Fast HMA Cross – visual only)

The script can optionally display a Fast HMA (e.g., 20) alongside the Slow HMA (e.g., 55).

Bullish early hint: Fast HMA crosses above Slow HMA, or stays above, before the Slow HMA officially turns green.

Bearish early hint: opposite.

⚠️ These signals are not part of the built-in logic — they are purely discretionary:

Advantage: Earlier entries, more profit potential.

Risk: Higher chance of whipsaws.

Practical workflow (early long entry):

Fast HMA crosses above Slow HMA AND Close > KC Basis.

Enter small position with tight stop (under KC Basis or HMA swing).

Once Slow HMA confirms green → add to position or trail stop tighter.

6) Recommended Presets

Crypto (1h/2h):

HMA: 55 / 10 / 0.20–0.30%

KC: 20 / 1.5–1.8

Spikes: ATR+Z, ATR=14, Z=20, Cooldown 5

FX (1h/4h):

HMA: 55 / 8–10 / 0.10–0.25%

KC: 20 / 1.2–1.5

Indices (15m/1h):

HMA: 50–60 / 8–12 / 0.15–0.30%

KC: 20 / 1.3–1.6

Fine-tuning:

Too noisy? → Raise slope threshold or increase HMA length.

Too sluggish? → Lower slope threshold or shorten HMA length.

7) Alerts – Best Practice

Long/Short Entry – get notified when trend color switches & KC filter is valid.

Long/Short Exit – for KC exits or fallback exits.

Long/Short Spike TP – for discretionary profit-taking.

Set via TradingView: Create Alert → Select this indicator → choose condition.

8) Common Pitfalls & Tips

Too many false signals?

Raise slope threshold (more “Sideways” filtering).

Enable KC filter for entries.

Entries too late?

Use Fast HMA cross for early discretionary entries.

Or lower slope threshold slightly.

Spikes too rare/frequent?

More frequent → ATR mode or lower ATR multiplier / Z-threshold.

Rarer but stronger → ATR+Z with higher thresholds.

9) Example Playbook (Long Trade)

Regime: Slow HMA still red, Fast HMA crosses upward (early hint).

Filter: Close > KC Basis.

Early Entry: Small size, stop below KC Basis or recent swing low.

Confirmation: Slow HMA turns green → scale up or trail stop.

Management: Partial profits at Spike-TP marker; full exit at KC upper band break.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.