Skip to content
Docs
Open Portal
Copy manually

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

Create and update a practice alert

Follow the TradingView alert dialog one field at a time, check the log, and replace the saved alert after changing your script.

You will create a TradingView alert for the Cross event from lesson 2, then learn what to do when you change the script.

Continue with My EMA practice on your BITSTAMP:BTCUSD, 1-minute candlestick chart. You should already see the markers from lesson 2. Your TradingView account needs access to script alerts and an available alert slot to complete the live exercise.

Click Copy on the code block below, on this lesson page. You will replace the code in the same saved My EMA practice script. The screenshots are reference pictures you can enlarge; their pictured buttons do not control TradingView.

Complete indicator with a text-only practice alertPine v6
TradingView → Pine Editor Pine Script
//@version=6
indicator("Pine practice: alerts", overlay = true)
int length = input.int(20, "EMA length", minval = 1)
string practiceLabel = input.string("Practice A", "Practice label")
float ema = ta.ema(close, length)
bool aboveEma = close > ema
bool crossedUp = ta.crossover(close, ema)
bool confirmedCross = crossedUp and barstate.isconfirmed
plot(ema, title = "EMA", color = color.blue, linewidth = 2)
bgcolor(aboveEma and barstate.isconfirmed ? color.new(color.blue, 90) : na)
plotshape(confirmedCross, title = "Cross above EMA", style = shape.triangleup,
location = location.belowbar, color = color.blue, size = size.small, text = "Cross")
// Learning message only. Leave Webhook URL disabled when creating the alert.
if confirmedCross
alert(practiceLabel + " | " + syminfo.ticker + " | close crossed above EMA " + str.tostring(length), alert.freq_once_per_bar_close)
1

Paste into your existing practice script

In TradingView, click Pine. With My EMA practice open, click inside the code, select all, and paste.

On Mac: Cmd+A, then Cmd+V. On Windows: Ctrl+A, then Ctrl+V.

What you should see

The editor contains the complete version above, including if confirmedCross and its indented alert(...) line at the bottom.

The indented alert call at the bottom of the practice script
Enlarge screenshot
Check that alert(...) is indented underneath if confirmedCross. Copy the complete code block above; the long message may extend beyond the visible editor area.

Check that alert(...) is indented underneath if confirmedCross. Copy the complete code block above; the long message may extend beyond the visible editor area.

The indented alert call at the bottom of the practice script
2

Save and update the chart

Click the cloud-shaped Save control, or press Cmd+S or Ctrl+S. Click Update on chart if it appears. If the practice indicator is missing from the chart, click the triangle-shaped Add to chart button.

Still shows Pine practice: signals? Check that the new source was saved and applied to this chart before opening the alert dialog.

What you should see

The chart label is now Pine practice: alerts. Your EMA and Cross markers are still visible.

Practice chart with Pine practice: alerts and a Cross marker
Enlarge screenshot
The chart label should now read Pine practice: alerts. Your EMA, shading and Cross markers remain visible.

The chart label should now read Pine practice: alerts. Your EMA, shading and Cross markers remain visible.

Practice chart with Pine practice: alerts and a Cross marker
3

Set the two practice inputs

Hover over Pine practice: alerts on the chart and click its Settings gear.

What you should see

The current chart script uses EMA length 20 and Practice label Practice A.

Settings gear for the Pine practice: alerts indicator
Enlarge screenshot
Use the gear beside Pine practice: alerts to open this indicator’s Inputs.

Use the gear beside Pine practice: alerts to open this indicator’s Inputs.

Settings gear for the Pine practice: alerts indicator

Open Inputs. Set EMA length to 20 and Practice label to Practice A, then click Ok.

Practice alert Inputs showing EMA length 20 and Practice A
Enlarge screenshot
Set EMA length to 20 and Practice label to Practice A, then click Ok. These are the values the new alert will capture.

Set EMA length to 20 and Practice label to Practice A, then click Ok. These are the values the new alert will capture.

Practice alert Inputs showing EMA length 20 and Practice A

The script can describe an alert event, but it does not create a running alert for you. Follow each field below; choosing the indicator alone is not enough.

Chart toolbar crowded? Click the minus button at the top of Pine Editor to collapse it. Your saved practice indicator stays on the chart.

Pine Editor collapse control highlighted above Publish script
Enlarge screenshot
If the chart toolbar is crowded, collapse Pine Editor with its minus button. Your saved script stays on the chart.

If the chart toolbar is crowded, collapse Pine Editor with its minus button. Your saved script stays on the chart.

Pine Editor collapse control highlighted above Publish script
4

Open the alert dialog

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

What you should see

The Create alert dialog appears over your 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
5

Choose Pine practice: alerts

Open Condition and select Pine practice: alerts.

The indicator is missing? Close this dialog, finish steps 1–2, and confirm the chart shows Pine practice: alerts. Then open the alert dialog again.

What you should see

Condition refers to your practice indicator. The event may still say Crossing; change it in the next step.

Condition menu showing the Pine practice: alerts script
Enlarge screenshot
Open Condition and choose Pine practice: alerts. Match the script name and its 20 / Practice A inputs.

Open Condition and choose Pine practice: alerts. Match the script name and its 20 / Practice A inputs.

Condition menu showing the Pine practice: alerts script

Not finished yet: Crossing is a generic comparison. Leaving it selected will not listen to the alert(...) call you added to the script.

Generic Crossing comparison selected instead of the script alert event
Enlarge screenshot
This is not ready yet: Crossing compares values. Change this event to Any alert() function call before creating the practice alert.

This is not ready yet: Crossing compares values. Change this event to Any alert() function call before creating the practice alert.

Generic Crossing comparison selected instead of the script alert event
6

Choose Any alert() function call

Click the event menu that currently says Crossing. Select Any alert() function call.

What you should see

The selected event reads Any alert() function call, rather than Crossing.

Event menu with Any alert() function call highlighted
Enlarge screenshot
Choose Any alert() function call at the top of this menu. This is the event defined by your alert(...) code.

Choose Any alert() function call at the top of this menu. This is the event defined by your alert(...) code.

Event menu with Any alert() function call highlighted
7

Check the alert interval

Check Interval. The example shows Same as chart with 1 minute. Keep that choice if your chart is on 1 minute. Otherwise, select the 1-minute interval before continuing.

What you should see

The alert interval and your chart interval are both 1 minute.

Alert condition set to Any alert() function call and Same as chart 1 minute
Enlarge screenshot
You should see Any alert() function call and a 1-minute interval. The generic Crossing comparison and numeric Value field should be gone.

You should see Any alert() function call and a 1-minute interval. The generic Crossing comparison and numeric Value field should be gone.

Alert condition set to Any alert() function call and Same as chart 1 minute
8

Turn off Webhook URL

Open Notifications. If Webhook URL is checked, click its checkbox to clear it. For quiet practice, leave the other notification options off too, then click Apply.

Events can still appear in TradingView’s alert log with notification options off.

What you should see

Webhook URL is unchecked. An address can remain in the inactive field, but the option itself must be off.

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
9

Name the practice alert

Open Message. In Alert name, type EMA practice A, then click Apply.

The actual event message comes from your code. The alert’s name helps you find this alert in the list.

What you should see

The alert's name is EMA practice A. You have not pasted a PineConnector message into this dialog.

Alert name set to EMA practice A with Apply highlighted
Enlarge screenshot
Enter EMA practice A, then click Apply. This names the alert; the script still supplies the event message.

Enter EMA practice A, then click Apply. This names the alert; the script still supplies the event message.

Alert name set to EMA practice A with Apply highlighted
10

Create and locate the alert

Check the script, 1-minute interval and name EMA practice A. Notifications should read None. Review the expiration, then click Create.

TradingView asks you to upgrade or says you have no alert slots? The live alert has not been created. You can still work through the saved-alert illustration below; keep the live-message check incomplete.

What you should see

EMA practice A appears in your alerts list. It must be active to evaluate future events.

Final practice-alert review showing Notifications None and Create
Enlarge screenshot
Check the script, 1-minute interval and name EMA practice A. Notifications should read None for this quiet exercise. Then click Create.

Check the script, 1-minute interval and name EMA practice A. Notifications should read None for this quiet exercise. Then click Create.

Final practice-alert review showing Notifications None and Create

Open Alerts on the chart’s right-hand toolbar. Click the search icon, type EMA practice, and find EMA practice A. Check that its status says Active.

Alerts panel filtered to the active EMA practice A alert
Enlarge screenshot
Open Alerts on the right, use the search icon to find EMA practice, and confirm EMA practice A shows Active.

Open Alerts on the right, use the search icon to find EMA practice, and confirm EMA practice A shows Active.

Alerts panel filtered to the active EMA practice A alert

Shows Activating? Wait for it to change to Active. Shows Stopped manually? That alert is paused and will not evaluate new events.

11

Open the alert log

Click the Log tab beside Alerts. Look for an entry from EMA practice A after a new confirmed upward cross.

What you should see

You can inspect the messages TradingView generated. A listed alert and a message in the log are different things.

Log tab beside Alerts in the right-hand panel
Enlarge screenshot
Click Log beside Alerts to see generated messages. The alert list and its log are different views.

Click Log beside Alerts to see generated messages. The alert list and its log are different views.

Log tab beside Alerts in the right-hand panel

This is a real message from the practice example. Your timestamp will differ. Look for the same message text in your own log:

Real TradingView log message from EMA practice A
Enlarge screenshot
This captured practice event contains Practice A, BTCUSD and EMA 20. Your timestamp will differ. No webhook was enabled for this alert.

This captured practice event contains Practice A, BTCUSD and EMA 20. Your timestamp will differ. No webhook was enabled for this alert.

Real TradingView log message from EMA practice A

The log is empty? A new upward cross may not have happened yet. Historical Cross markers do not send old messages when you create an alert. A 1-minute chart gives you more candle closes to observe; it does not guarantee a crossover.

You can continue to the saved-alert exercise while you wait. Until a real entry appears, the live-message check remains pending.

When an entry appears, open it and compare:

Check Expected result for this version
Message label Starts with Practice A.
Chart ticker Contains BTCUSD on this example chart.
EMA length Ends with EMA 20.
Event Corresponds to a new confirmed Cross on the same symbol, interval and inputs.
Copies One entry from your intended practice alert for that event.

The message describes a chart event. It does not establish PineConnector receipt or a broker order.

No entry after an apparent new cross? Check that the alert is active, has not expired, and uses Any alert() function call. Confirm that the chart’s symbol, interval and inputs still match the saved alert before comparing their results.

Now that you have configured the dialog, look at the line it listens to:

The call your alert listens toExcerpt from the complete script. Keep this line indented below if confirmedCross.
Read at the bottom of My EMA practice Pine Script
// Learning message only. Leave Webhook URL disabled when creating the alert.
if confirmedCross
alert(practiceLabel + " | " + syminfo.ticker + " | close crossed above EMA " + str.tostring(length), alert.freq_once_per_bar_close)

if confirmedCross runs the indented line only when the condition is true. alert.freq_once_per_bar_close waits for the realtime candle’s closing update. The + signs join the message text, and str.tostring(length) inserts the length as text. TradingView’s alert() guidance

An existing alert keeps a saved copy of the script, inputs, symbol and interval from its creation. Changing the chart later does not update that copy. TradingView explains the saved snapshot.

First try the illustration: create the sample alert at 20 / Practice A, then change the current settings to 50 / Practice B. Watch which side changes.

Try the ideaThe chart changes. The saved alert does not.

Create a sample alert, then change the script settings. Which values does the saved alert keep?

On your chartCurrent script
EMA length
20
Message label
Practice A
Captured when you create itSaved sample alert

No sample alert yet. Create one to capture the current script values.

Not created

First, create the sample alert with length 20 and message label Practice A.

This is a local teaching example, not a TradingView control. Practice A and Practice B are message labels, not PineConnector commands. Nothing is sent and no orders are placed.

Read the complete example
  1. Begin with EMA length 20 and message label Practice A. There is no saved sample alert yet.
  2. Create the sample alert. It captures length 20 and message label Practice A.
  3. Change the current script to length 50 and message label Practice B. The saved sample alert still contains length 20 and Practice A.
  4. Recreate the sample alert. It now captures length 50 and Practice B. Further script changes still do not update it automatically.

Now make the same change in TradingView, replacing the active practice alert:

12

Pause the earlier practice alert

Click the Alerts tab to return to the list. Right-click EMA practice A, then choose Pause at the top of its menu.

What you should see

EMA practice A is paused, so it cannot keep generating events while you create its replacement.

Practice alert context menu with Pause highlighted
Enlarge screenshot
Right-click EMA practice A and choose Pause, the first menu item. This stops this practice alert without deleting its settings.

Right-click EMA practice A and choose Pause, the first menu item. This stops this practice alert without deleting its settings.

Practice alert context menu with Pause highlighted

Check that A now says Stopped manually. Leave it stopped while you create B.

EMA practice A showing Stopped manually
Enlarge screenshot
Stopped manually confirms that practice alert A is paused. Leave it stopped while you create its replacement.

Stopped manually confirms that practice alert A is paused. Leave it stopped while you create its replacement.

EMA practice A showing Stopped manually
13

Change the chart's practice inputs

Open the Settings gear for Pine practice: alerts on the chart. In Inputs, set EMA length to 50 and Practice label to Practice B. Click Ok.

What you should see

The chart now uses EMA length 50 and Practice label Practice B. The earlier alert still has its saved values.

Practice inputs changed to EMA length 50 and Practice B
Enlarge screenshot
Change the chart inputs to 50 and Practice B, then click Ok. The earlier alert remains paused with its previously saved inputs.

Change the chart inputs to 50 and Practice B, then click Ok. The earlier alert remains paused with its previously saved inputs.

Practice inputs changed to EMA length 50 and Practice B
14

Create the replacement alert

Repeat steps 4–10 to create a new alert. Use these settings:

  • Condition: Pine practice: alerts.
  • Event: Any alert() function call.
  • Interval: 1 minute.
  • Notifications: Webhook URL off.
  • Alert name: EMA practice B.

Check the alert list: B should say Active, while A still says Stopped manually. If B says Activating, wait for Active.

What you should see

The new alert captures your current 50 / Practice B inputs. The earlier practice alert remains paused.

Practice B active while practice A remains stopped
Enlarge screenshot
B is the active replacement. A still shows Stopped manually. If B says Activating, wait until it changes to Active.

B is the active replacement. A still shows Stopped manually. If B says Activating, wait until it changes to Active.

Practice B active while practice A remains stopped

At the next qualifying event, use the Log tab to verify a message beginning Practice B and ending EMA 50.

Renaming A would only change its name. It would not make it capture the new script inputs. For future source-code edits, save and update the chart before creating the replacement alert.

15

Stop the practice alerts when you finish

In the Alerts list, right-click EMA practice B and choose Pause. Check both practice rows. If A is still active, pause A too.

What you should see

Both EMA practice A and EMA practice B show Stopped manually.

Both practice alerts showing Stopped manually
Enlarge screenshot
When you finish, pause both practice alerts. A and B should each show Stopped manually.

When you finish, pause both practice alerts. A and B should each show Stopped manually.

Both practice alerts showing Stopped manually

If no real event appeared in your own log during the lesson, you have practised configuration and replacement, but your live-message check is still pending.

You now know how to create the correct alert type, find its log and replace its saved settings. Continue with numbers, text and inputs to finish the foundations. Keep Webhook URL off during the practice lessons.

Later, Build a PineConnector message begins the connection stage of this course. It teaches the destination, command, broker symbol and sizing before you enable delivery. Keep PineConnector Syntax nearby, and use the course’s demo-verification lesson when you reach that stage.

The checks remain separate: TradingView generated the message → PineConnector received and processed it → the broker account shows the expected result. A strategy’s simulated order-fill events are another alert mechanism; use the strategy instructions when that is your starting script.