OPEN-SOURCE SCRIPT
HMA Pivot Buy/Sell (only) + Alerts

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}}.
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}}.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.