OPEN-SOURCE SCRIPT

HMA Pivot Buy/Sell (only) + Alerts

114
This Pine Script is a lightweight indicator that plots only HMA-based pivot Buy/Sell signals and provides alert conditions for them.

What it does

Calculates a Hull Moving Average (HMA) using either:

a dynamic length based on the chart timeframe, or

a custom user-defined length.

Detects HMA pivot points (local turning points):

Buy signal when the HMA forms a local minimum (trend turns up).

Sell signal when the HMA forms a local maximum (trend turns down).

Optionally plots the HMA line and prints only the Buy/Sell markers on the chart (no extra arrows/emoji/labels from other systems).

Adds TradingView alerts for Buy, Sell, and combined Buy/Sell events.

Signal logic

Buy (HMA Pivot Low) triggers when:

HMA > HMA[1] and HMA[1] < HMA[2]

Meaning: the HMA was falling, formed a bottom, and has started rising.

Sell (HMA Pivot High) triggers when:

HMA < HMA[1] and HMA[1] > HMA[2]

Meaning: the HMA was rising, formed a top, and has started falling.

Inputs

Source: price source used to compute HMA (default: close).

Use Custom HMA Length: enables manual override.

Custom HMA Length: manual HMA period (default: 55).

Alerts: only on bar close:

If enabled, alerts fire only after the bar closes (confirmed signals).

If disabled, alerts can fire intrabar (faster but less stable).

Draw signal on pivot bar (offset -1):

If enabled, markers are drawn on the pivot bar (one bar back) using offset = -1.

If disabled, markers are drawn on the confirmation bar (no offset).

Show HMA line: toggles display of the HMA line.

Alerts available

BUY (HMA Pivot) — triggers on Buy signal.

SELL (HMA Pivot) — triggers on Sell signal.

BUY/SELL (HMA Pivot) — triggers on either Buy or Sell.

Each alert message includes ticker, timeframe, and close price via placeholders:
{{ticker}}, {{interval}}, {{close}}.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.