Skip to content
Docs
Open Portal
Copy manually

Your browser did not allow direct clipboard access. Select and copy the text below.

Choose an indicator alert method

Compare alert() with named alertcondition() events, then configure one named text-only alert and check its message settings.

So far you have chosen Any alert() function call in TradingView. Some indicators instead offer named choices such as Practice long entry. You will use the same chart conditions to see how that route differs.

Keep earlier practice alerts paused. This lesson uses informational messages only, with Webhook URL off. An available TradingView script-alert slot is needed to create the practice alert; the code and dialog comparison are still useful without one.

Click Copy on the code block below. This version uses alertcondition(...) instead of alert(...) and starts with Enable signal alerts off.

Complete indicator with named entry and exit alert choicesPine v6
TradingView → Pine Editor → My EMA practice Pine Script
//@version=6
indicator("Pine practice: named alerts", overlay = true)
int length = input.int(20, "Signal EMA length", minval = 1)
int trendLength = input.int(100, "Trend EMA length", minval = 1)
bool useTrendFilter = input.bool(false, "Use trend filter")
bool useSessionFilter = input.bool(false, "Use entry session filter")
string entrySession = input.session("0900-1700", "Entry session")
string sessionTimezone = input.string("Etc/UTC", "Session time zone", options = ["Etc/UTC", "America/New_York", "Asia/Singapore"])
bool enableSignalAlerts = input.bool(false, "Enable signal alerts")
float ema = ta.ema(close, length)
float trendEma = ta.ema(close, trendLength)
bool crossedUp = ta.crossover(close, ema)
bool crossedDown = ta.crossunder(close, ema)
bool trendAllowed = not useTrendFilter or close > trendEma
bool inEntrySession = not na(time(timeframe.period, entrySession, sessionTimezone))
bool sessionAllowed = not useSessionFilter or inEntrySession
bool entrySignal = crossedUp and barstate.isconfirmed and trendAllowed and sessionAllowed
bool exitSignal = crossedDown and barstate.isconfirmed
plot(ema, title = "Signal EMA", color = color.blue, linewidth = 2)
plot(useTrendFilter ? trendEma : na, title = "Trend EMA", color = color.orange, linewidth = 2)
bgcolor(useSessionFilter and not inEntrySession ? color.new(color.gray, 88) : na, title = "Outside entry session")
plotshape(entrySignal, title = "Long entry signal", style = shape.triangleup,
location = location.belowbar, color = color.green, size = size.small, text = "Entry")
plotshape(exitSignal, title = "Long exit signal", style = shape.triangledown,
location = location.abovebar, color = color.orange, size = size.small, text = "Exit")
// Each call adds one named choice to the indicator's alert menu.
// These are constant message templates; TradingView fills the placeholders.
alertcondition(enableSignalAlerts and entrySignal, "Practice long entry", "Practice long entry | {{ticker}} | close={{close}}")
alertcondition(enableSignalAlerts and exitSignal, "Practice long exit", "Practice long exit | {{ticker}} | close={{close}}")
var table preview = table.new(position.top_right, 1, 3, border_width = 1)
if barstate.islast
table.cell(preview, 0, 0, "Named alert message templates", bgcolor = color.blue, text_color = color.white)
table.cell(preview, 0, 1, "Practice long entry | {{ticker}} | close={{close}}", bgcolor = color.white, text_color = color.black)
table.cell(preview, 0, 2, "Practice long exit | {{ticker}} | close={{close}}", bgcolor = color.white, text_color = color.black)
1

Replace and save the practice script

Open Pine. Click inside My EMA practice, select all with Cmd+A / Ctrl+A, and paste with Cmd+V / Ctrl+V. Save and update the chart if asked.

What you should see

The chart label reads Pine practice: named alerts. Entry and Exit markers remain, with a box showing their message templates.

TradingView right-hand toolbar with the Pine Editor icon highlighted
Enlarge screenshot
Click Pine in the far-right toolbar. This opens the code editor; it does not create a trade.

Click Pine in the far-right toolbar. This opens the code editor; it does not create a trade.

TradingView right-hand toolbar with the Pine Editor icon highlighted

The braces in the preview, such as {{ticker}}, are expected. This box displays a message template. TradingView replaces supported placeholders when an alert using that template fires; the box is not a log of sent events.

2

Prepare one text-only practice alert

Open the settings gear for Pine practice: named alerts, then Inputs. Set Signal EMA length to 20. Uncheck Use trend filter and Use entry session filter.

Check Enable signal alerts, then click Ok. These settings will be captured when you create the new alert. They do not change an older saved alert.

What you should see

The chart uses signal length 20, both optional filters off, and Enable signal alerts on.

3

Open Create alert

If Pine Editor crowds the chart toolbar, collapse it with its minus button. Click the alarm-clock icon with a plus sign in the top chart toolbar.

What you should see

The alert dialog is open for your current practice chart.

Create alert icon in the TradingView chart toolbar
Enlarge screenshot
Click the alarm-clock icon with a plus sign in the chart’s top toolbar. Its tooltip is Create alert.

Click the alarm-clock icon with a plus sign in the chart’s top toolbar. Its tooltip is Create alert.

Create alert icon in the TradingView chart toolbar
4

Select Practice long entry

Under Condition, choose Pine practice: named alerts. Open its event menu and select Practice long entry.

No Any alert() function call option? That is expected for this version. Its source uses named alertcondition(…) events instead.

What you should see

The selected event is Practice long entry. This alert will not listen to the separate Practice long exit condition.

The indicator event menu contains Practice long entry and Practice long exit above the generic crossing choices.
Enlarge screenshot
Choose Practice long entry (1) for this exercise. Practice long exit (2) is a separate event that would need its own alert.

Choose Practice long entry (1) for this exercise. Practice long exit (2) is a separate event that would need its own alert.

The indicator event menu contains Practice long entry and Practice long exit above the generic crossing choices.
5

Check the interval, trigger and message

Keep the 1-minute interval. Open Trigger, which may start at Once only, and select Once per bar close. Open Message and inspect the default message.

Keep its entry text and the {{ticker}} and {{close}} placeholders. Do not paste the full Pine Script into this field. Name the alert Named entry practice, then apply the settings.

What you should see

The interval is 1 minute, the trigger is Once per bar close, and the default message contains the entry text and placeholders.

Named entry alert with Practice long entry selected, Once per bar close, Notifications None and Create.
Enlarge screenshot
Review the named event (1), Once per bar close (2) and Notifications None (3) before selecting Create (4).

Review the named event (1), Once per bar close (2) and Notifications None (3) before selecting Create (4).

Named entry alert with Practice long entry selected, Once per bar close, Notifications None and Create.
Edit message dialog for Named entry practice with ticker and close placeholders in the message.
Enlarge screenshot
Name the alert (1), keep the message template and its double-brace placeholders (2), then click Apply (3). TradingView fills those placeholders when an event occurs.

Name the alert (1), keep the message template and its double-brace placeholders (2), then click Apply (3). TradingView fills those placeholders when an event occurs.

Edit message dialog for Named entry practice with ticker and close placeholders in the message.

A custom-script warning appears? Open its help and follow the warning checks. Do not treat the warning as proof that every script is safe or that a confirmed-bar condition resolves every source of repainting.

6

Keep notifications off and create the alert

Open Notifications. Leave every option, including Webhook URL, unchecked. Click Apply, review the dialog, and click Create.

Open Alerts on the right and find Named entry practice. If TradingView prevents creation because of account access or slot limits, the live test remains incomplete.

What you should see

Named entry practice appears as Active in the Alerts list.

Notifications panel with Webhook URL unchecked and Apply highlighted
Enlarge screenshot
Webhook URL must be unchecked. This quiet practice example leaves every notification checkbox off. Click Apply to return to the alert dialog.

Webhook URL must be unchecked. This quiet practice example leaves every notification checkbox off. Click Apply to return to the alert dialog.

Notifications panel with Webhook URL unchecked and Apply highlighted

At the next eligible upward cross, inspect this alert in the Log tab. The message should start Practice long entry, with the chart ticker and closing price substituted for the placeholders. A downward-cross Exit marker alone should not trigger this entry alert. Historical markers do not send old events when you create it.

Question alert() alertcondition() in an indicator
What do you select? Any alert() function call. One named event, such as Practice long entry.
Where is the message built? In the Pine code, including changing text or numbers. A constant default template in code, editable in the alert dialog. Supported placeholders can supply values.
Where is frequency set? In the code’s freq argument. In the alert dialog.
Can one created alert cover entry and exit? Yes, if both calls are in the script and allowed by its logic and frequency. Each created alert listens to its chosen named condition.

These are two routes, not two proficiency levels. The next module uses alert() again because it builds a PineConnector message from inputs. Named conditions remain useful when adapting an indicator that already exposes separate alert choices. TradingView’s alerts reference

{{ticker}} is not a universal Pine variable. This lesson’s named-alert template supports that placeholder. In an alert() message, use Pine values such as syminfo.ticker and convert numbers with str.tostring(...); do not expect alert() to substitute template placeholders. TradingView’s alerts FAQ

7

Pause the named practice alert and reset the chart input

In the Alerts list, right-click Named entry practice and choose Pause. Check for Stopped manually.

Then open the indicator’s Settings → Inputs, uncheck Enable signal alerts, and click Ok. Keep both optional filters off for the next module.

What you should see

Named entry practice shows Stopped manually, and Enable signal alerts is unchecked on the chart.

Named entry practice appears in the filtered Alerts list with status Stopped manually.
Enlarge screenshot
Finish with Named entry practice showing Stopped manually. Stopping this alert is separate from changing a checkbox on the chart.

Finish with Named entry practice showing Stopped manually. Stopping this alert is separate from changing a checkbox on the chart.

Named entry practice appears in the filtered Alerts list with status Stopped manually.

Do both actions: the saved alert and the current chart are separate copies. A false default in replacement source code also does not reliably reset an input value already chosen on the chart.

Question: you selected Practice long entry. Will the same alert send the Practice long exit message?

Show the answer

No. It listens to the selected entry condition. The exit condition is a separate named choice and would need its own alert if you wanted to use that route for both events.

Question: can you copy this template’s {{ticker}} text into an alert() call and expect it to be substituted?

Show the answer

No. For alert(), build the string using Pine values such as syminfo.ticker. The message-building mechanism must match the alert method.