Indicator · Pine Script v6 · On the chart

Alert Examples

by trugurpala

This indicator calculates fast and slow exponential moving averages along with RSI for detecting crossovers and overbought/oversold conditions.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code74
Settings3inputs
LicenceMIT
Last update2 months ago3 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

74 lines of Pine Script v6 from webhook-templates/02_pine_alert_conditions.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

02_pine_alert_conditions.pine
//@version=6
// Alert Conditions — Complete Reference
// github.com/trugurpala/pinescriptv6 — Author: Ugur Pala
indicator("Alert Examples [trugurpala]", overlay=true)

// ── Inputs ───────────────────────────────────────────────────────────────────
int fastLen = input.int(9,  "Fast EMA", minval=1)
int slowLen = input.int(21, "Slow EMA", minval=1)
int rsiLen  = input.int(14, "RSI",      minval=1)

// ── Calculations ─────────────────────────────────────────────────────────────
float fastEma  = ta.ema(close, fastLen)
float slowEma  = ta.ema(close, slowLen)
float rsi      = ta.rsi(close, rsiLen)
float atr      = ta.atr(14)

bool bullCross = ta.crossover(fastEma,  slowEma)
bool bearCross = ta.crossunder(fastEma, slowEma)
bool rsiOb     = ta.crossunder(rsi, 70)
bool rsiOs     = ta.crossover(rsi,  30)

// ── alertcondition() — Kullanıcı manuel alarm kurar ──────────────────────────
// TR: TradingView'da elle alarm oluşturmak için
// EN: For manually creating alerts in TradingView UI
alertcondition(bullCross,
    title   = "EMA Bull Cross",
    message = "🟢 EMA Bull | {{ticker}} | {{interval}} | {{close}}")

alertcondition(bearCross,
    title   = "EMA Bear Cross",
    message = "🔴 EMA Bear | {{ticker}} | {{interval}} | {{close}}")

alertcondition(rsiOb,
    title   = "RSI Overbought Exit",
    message = "⚠️ RSI OB Exit | {{ticker}} | RSI seviyesi 70 altına düştü")

alertcondition(rsiOs,
    title   = "RSI Oversold Exit",
    message = "⚠️ RSI OS Exit | {{ticker}} | RSI seviyesi 30 üstüne çıktı")

// ── alert() — Kod içinde tetiklenir ──────────────────────────────────────────
// TR: Koşul gerçekleşince otomatik tetiklenir
// EN: Fires automatically when condition is met

// Her bar başına bir kez
if bullCross
    alert("🟢 BULL CROSS | " + syminfo.ticker + " | " + str.tostring(close),
          alert.freq_once_per_bar)

// Sadece bar kapanışında
if bearCross
    alert("🔴 BEAR CROSS | " + syminfo.ticker + " | " + str.tostring(close),
          alert.freq_once_per_bar_close)

// Her tickte (dikkatli kullan!)
// if someCondition
//     alert("msg", alert.freq_all)

// ── JSON webhook örneği ───────────────────────────────────────────────────────
// TR: Bu mesajı TradingView Alert → Message kutusuna yapıştır
// EN: Paste this in TradingView Alert → Message box
// {
//   "symbol":   "{{ticker}}",
//   "action":   "buy",
//   "price":    {{close}},
//   "interval": "{{interval}}",
//   "atr":      "hesaplanacak"
// }

// ── Visuals ──────────────────────────────────────────────────────────────────
plot(fastEma, "Fast", fastEma > slowEma ? color.green : color.red, linewidth=2)
plot(slowEma, "Slow", fastEma > slowEma ? color.lime  : color.orange, linewidth=2)
plotshape(bullCross, "Bull", shape.triangleup,   location.belowbar, color.green)
plotshape(bearCross, "Bear", shape.triangledown, location.abovebar, color.red)

Overview

Alert Examples plots the two EMAs on the price chart with dynamic coloring and displays triangle shapes on crossovers. Bullish cross triggers a buy alert while bearish cross signals a sell alert; RSI levels provide additional exit conditions. Inputs control the lengths of the EMAs and RSI period. Signals fire as alerts that can connect to external webhooks for automated trading systems. The indicator draws directly on the main price chart without separate panes.

Details

Published by

trugurpala on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Oscillators & momentum, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

aialgorithmic-tradingclaude-codecodexcoding-agentsgithub-copilotopen-sourcepine-scriptpine-script-v6technical-analysis

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Fast EMAint9fastLen
Slow EMAint21slowLen
RSIint14rsiLen
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

114 stars

This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points

Indicator v4 Support & resistanceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Support and Resistance Levels

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
14 stars

Self-Aware Trend System calculates volatility-adaptive ATR trailing bands using a Trend Quality Index engine that evaluates market efficiency, momentum persistence, and structural pivots. It plots adaptive trend bands and character-flip trend signals directly

Indicator v6 TrendVolatility & bands
Updated 2 weeks ago · MIT GitHub repository of Self-Aware Trend System [WillyAlgoTrader]

SPY 0DTE Scalper - 15min

by chris-c-thomas
14 stars

This intraday overlay establishes directional bias and high-conviction swing setups for SPY on the 15-minute timeframe. It computes a weighted confluence score combining an EMA ribbon, a 50 EMA anchor, session VWAP bands, RSI divergence, ADX, TTM Squeeze, cand

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · MIT GitHub repository of SPY 0DTE Scalper - 15min

Market Trend

by azamiftikhar1000
12 stars

Market Trend is an overlay indicator that identifies market direction and key price levels. It calculates a Relative Strength Index with Bollinger Bands to construct a 20-step color gradient reflecting momentum shifts. The script incorporates exponential movin

Indicator v4 TrendOscillators & momentum
Updated 3 years ago · None stated GitHub repository of Market Trend

BTE Acc AO SMIO

by f-cksociety
11 stars

This script provides an indicator-based backtesting engine framework that simulates trade entries, exits, and filtering directly on the price chart. It evaluates selected entry rules and multi-layered filters, including moving average trends, volume increases,

Indicator v5 TrendOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of BTE Acc AO SMIO

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers