Skip to content
Docs
Open Portal
Copy manually

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

Choose strategy alert events

Practise order-fill alerts and alert() calls separately, with the message field and saved inputs matched to the chosen event.

A strategy can send a message when its code calls alert(), when its simulated order fills, or through both sources. You will practise one route at a time and recognise the message each produces.

Continue with My strategy practice from Understand a Pine Script strategy. Use the same symbol, interval and standard candles. Your account needs an available script-alert slot for the live exercise.

Click Copy below. In TradingView, open Pine, select all the code inside My strategy practice, and replace it. Save, then update the chart if offered. The chart label becomes Pine practice: strategy alerts.

Complete strategy with separate informational alert routesPine v6 · Text-only alerts
TradingView → Pine Editor Pine Script
//@version=6
strategy("Pine practice: strategy alerts", overlay = true, initial_capital = 1000000,
default_qty_type = strategy.fixed, default_qty_value = 1, pyramiding = 0,
calc_on_every_tick = false, calc_on_order_fills = false, process_orders_on_close = false)
int length = input.int(20, "EMA length", minval = 1)
bool enableSignalAlerts = input.bool(false, "Enable signal alerts")
bool enableFillAlerts = input.bool(false, "Enable order-fill alerts")
float ema = ta.ema(close, length)
bool crossedUp = ta.crossover(close, ema)
bool crossedDown = ta.crossunder(close, ema)
bool entrySignal = crossedUp and barstate.isconfirmed
bool exitSignal = crossedDown and barstate.isconfirmed
// Informational practice only. Leave Webhook URL disabled in TradingView.
if entrySignal and strategy.position_size == 0
strategy.entry("Practice long", strategy.long,
alert_message = "Practice fill | enter long | " + syminfo.ticker,
disable_alert = not enableFillAlerts)
if enableSignalAlerts
alert("Practice signal | enter long | " + syminfo.ticker, alert.freq_once_per_bar_close)
if exitSignal and strategy.position_size > 0
strategy.close("Practice long",
alert_message = "Practice fill | close long | " + syminfo.ticker,
disable_alert = not enableFillAlerts)
if enableSignalAlerts
alert("Practice signal | close long | " + syminfo.ticker, alert.freq_once_per_bar_close)
plot(ema, title = "EMA", color = color.blue, linewidth = 2)
plotshape(entrySignal, title = "Entry condition", style = shape.triangleup,
location = location.belowbar, color = color.blue, size = size.small, text = "Entry")
plotshape(exitSignal, title = "Exit condition", style = shape.triangledown,
location = location.abovebar, color = color.orange, size = size.small, text = "Exit")

Open the strategy’s Settings → Inputs. Confirm that Enable signal alerts and Enable order-fill alerts are both unchecked. Those are the source defaults, but inspect the current fields in case earlier chart inputs were retained. The simulation can still show trades with both unchecked; these switches control messages, not the simulated trading rules.

Both Enable signal alerts and Enable order-fill alerts are unchecked in the strategy Inputs.
Enlarge screenshot
Start with both routes off: signal alerts (1) and order-fill alerts (2). The strategy can still simulate trades while its messages are disabled.

Start with both routes off: signal alerts (1) and order-fill alerts (2). The strategy can still simulate trades while its messages are disabled.

Both Enable signal alerts and Enable order-fill alerts are unchecked in the strategy Inputs.
Route What causes the practice message Message begins with
Signal alert The guarded alert() call runs when this script places its simulated entry or close order. Practice signal
Order-fill alert TradingView’s broker emulator fills an eligible strategy order. Practice fill

The events can happen at different times. In this example, the decision is made at a bar close and the fill normally follows at the next bar’s open. Strategy alerts

1

Enable only the fill route

In the strategy’s Inputs, turn on Enable order-fill alerts. Keep Enable signal alerts off. Click Ok.

What you should see

Enable order-fill alerts is checked; Enable signal alerts is still unchecked.

Enable order-fill alerts is checked while Enable signal alerts remains unchecked.
Enlarge screenshot
For the fill exercise, enable order-fill alerts only. Leave the separate signal-alert route off.

For the fill exercise, enable order-fill alerts only. Leave the separate signal-alert route off.

Enable order-fill alerts is checked while Enable signal alerts remains unchecked.
2

Select the strategy and fill events

Click the alarm-clock-plus Create alert control in the chart’s top toolbar. Under Condition, select Pine practice: strategy alerts, then choose Order fills only in its event selector. Check that the alert uses your chart’s interval.

What you should see

The new alert listens to the practice strategy's simulated fills.

Do not choose the combined order-fill and alert() option for this exercise. If your script or dialog exposes no event selector, check which alert sources that script actually contains.

Strategy event menu offers combined events, Order fills only, and alert() function calls only.
Enlarge screenshot
Choose Order fills only for this exercise. The combined option listens to two event streams; the bottom option is the separate signal-alert route.

Choose Order fills only for this exercise. The combined option listens to two event streams; the bottom option is the separate signal-alert route.

Strategy event menu offers combined events, Order fills only, and alert() function calls only.

Open Message in the alert dialog. Replace the default message with this exact placeholder, including both pairs of braces:

The complete order-fill message field
TradingView → Create alert → Message Text
{{strategy.order.alert_message}}

Name the alert Strategy practice fills, then apply the message settings. The placeholder tells TradingView to use the alert_message attached to the order that filled. It is not a Pine expression to paste into the editor. Order-fill messages

Strategy practice fills uses exactly the strategy.order.alert_message placeholder in its Message field.
Enlarge screenshot
Name the practice alert (1), replace the entire Message with {{strategy.order.alert_message}} (2), then Apply (3). Keep both opening and closing brace pairs.

Name the practice alert (1), replace the entire Message with {{strategy.order.alert_message}} (2), then Apply (3). Keep both opening and closing brace pairs.

Strategy practice fills uses exactly the strategy.order.alert_message placeholder in its Message field.
3

Review the destination and create

Open Notifications. Leave Webhook URL and all other notification options off, then click Apply. Review the condition, interval and name before clicking Create.

What you should see

Strategy practice fills appears in the Alerts list as active.

An unavailable alert slot stops the live exercise here. You can still inspect the code and answer the questions below.

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

Open Alerts in the right toolbar and find the new alert. Wait for a qualifying future simulated fill, then open Log. Historical trades in the report do not produce old alert messages.

For the BTCUSD example, the entry message should be Practice fill | enter long | BTCUSD; an eligible close should say Practice fill | close long | BTCUSD. Keep the chart’s settings unchanged while comparing the new log entry with its simulated fill.

Wrong result: a generic strategy description instead of the practice message usually means the Message field was not set to the placeholder. A missing event also calls for checking the saved enable switch and whether a new fill occurred. Correct the setup and replace the alert; changing the chart does not update an existing alert’s saved inputs.

The entry contains these two arguments:

The message and its fill-alert guardExcerpt. Keep the surrounding strategy.entry call.
Read within the complete practice strategy Pine Script
alert_message = "Practice fill | enter long | " + syminfo.ticker,
disable_alert = not enableFillAlerts)

alert_message supplies the text. When disable_alert is true, that order’s fill alert is suppressed. The simulated order still exists. This example also supplies a message and guard on strategy.close(...); reviewing the entry alone would miss half the workflow.

  1. In Alerts, right-click Strategy practice fills, select Pause, and confirm Stopped manually.
Strategy practice fills is shown as Stopped manually in the filtered alert list.
Enlarge screenshot
Pause the practice alert itself and verify Stopped manually. A checkbox change on the chart does not stop this saved alert.

Pause the practice alert itself and verify Stopped manually. A checkbox change on the chart does not stop this saved alert.

Strategy practice fills is shown as Stopped manually in the filtered alert list.
  1. In the strategy’s Inputs, turn Enable order-fill alerts off and Enable signal alerts on. Click Ok.
  2. Create a fresh alert from Pine practice: strategy alerts, choosing alert() function calls only. Name it Strategy practice signals and keep all notifications, including the webhook, off.
  3. At a future qualifying event, inspect Log for Practice signal | enter long | BTCUSD or Practice signal | close long | BTCUSD.
  4. Pause Strategy practice signals when finished. Confirm that both practice alerts show Stopped manually.
  5. Open the chart strategy’s Settings → Inputs and uncheck both Enable signal alerts and Enable order-fill alerts. Click Ok, then check the two switches again before replacing this source in the next lesson.

For this route, the alert(...) call supplies the message. The order-fill placeholder is not what creates its text.

Reset both the saved alerts and the chart inputs. Pausing the alerts does not reset the chart’s switches, and pasting replacement source does not guarantee that retained input values return to its defaults.

You enable both input switches and select both event sources in one alert. Could a single intended entry produce a signal message and a later fill message?

Show the answer

Yes. This script can emit one message when it requests the simulated order and another when the emulator fills it. If both were mapped to the same broker entry, that could request two entries. Select the event route deliberately and check older alerts as well.

If the alert was created successfully but no qualifying future event appeared, configuration is complete while message observation remains pending. If TradingView prevented alert creation, both creation and message observation are incomplete. Keep those distinctions when you move to a PineConnector integration.