Skip to content
Docs
Open Portal
Copy manually

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

Connect your indicator

Inspect generated buy and close-buy messages in TradingView before enabling webhook delivery.

You will connect your entry and exit conditions to their messages, then inspect a future message in TradingView’s Log. Keep Webhook URL off throughout this lesson. PineConnector delivery begins in the next lesson.

Finish the message and sizing exercises first. For the live-message check, you need your intended demo connection’s License ID, exact broker symbol, reviewed sizing, any required signal secret, and an available TradingView script-alert slot. Without those, you can inspect the disabled chart preview and leave the live-message check pending.

Add the indicator that builds both messages

Section titled “Add the indicator that builds both messages”
1

Create a new working copy

Pause earlier practice alerts. Open Pine, then choose Create new → Indicator from the script-name menu. Copy the complete script below and replace all starter code.

What you should see

You have a separate indicator for the connection exercise.

Pine Editor script menu with Create new and Indicator highlighted
Enlarge screenshot
Open the script-name menu, choose Create new, then Indicator.

Open the script-name menu, choose Create new, then Indicator.

Pine Editor script menu with Create new and Indicator highlighted
Complete long-only connection indicatorPine v6
TradingView → Pine Editor Pine Script
//@version=6
indicator("Pine practice: connect indicator", overlay = true)
// This script can generate trading instructions when enabled. Start with webhook OFF.
bool enableSignals = input.bool(false, "Enable PineConnector messages", group = "Signals")
int length = input.int(20, "EMA length", minval = 1, group = "Signals")
string licenseId = input.string("", "License ID", group = "Destination", display = display.none)
string brokerSymbol = input.string("", "Exact broker symbol", group = "Destination", display = display.none)
string signalSecret = input.string("", "Signal secret (only if required)", group = "Destination", display = display.none)
string volumeMethod = input.string("Fixed lots", "Volume method", options = ["Fixed lots", "Cash loss at stop", "Balance loss at stop", "Equity loss at stop", "Balance as margin"], group = "Size and protection")
float lots = input.float(0.01, "Lots (Fixed lots only)", minval = 0.00000001, step = 0.01, group = "Size and protection", display = display.none)
float riskValue = input.float(1, "Cash / percent value (other methods)", minval = 0.00000001, group = "Size and protection", display = display.none)
float stopPips = input.float(20, "Stop loss (PineConnector pips; 0 = omit)", minval = 0, group = "Size and protection", display = display.none)
float targetPips = input.float(40, "Take profit (PineConnector pips; 0 = omit)", minval = 0, group = "Size and protection", display = display.none)
string volumeKey = volumeMethod == "Fixed lots" ? "vol_lots" : volumeMethod == "Cash loss at stop" ? "vol_dollar" : volumeMethod == "Balance loss at stop" ? "vol_pct_bal_loss" : volumeMethod == "Equity loss at stop" ? "vol_pct_eq_loss" : "vol_pct_bal_margin"
float amount = volumeMethod == "Fixed lots" ? lots : riskValue
string amountText = str.tostring(amount, "0.########")
string stopText = str.tostring(stopPips, "0.########")
string targetText = str.tostring(targetPips, "0.########")
bool needsStop = volumeMethod == "Cash loss at stop" or volumeMethod == "Balance loss at stop" or volumeMethod == "Equity loss at stop"
bool validLicense = str.length(licenseId) > 0 and str.match(licenseId, "^[0-9]+$") == licenseId
bool validSymbol = str.length(brokerSymbol) > 0 and not str.contains(brokerSymbol, ",") and not str.contains(brokerSymbol, "=") and not str.contains(brokerSymbol, " ") and not str.contains(brokerSymbol, "\n") and not str.contains(brokerSymbol, "\r") and not str.contains(brokerSymbol, "\t")
bool validSecret = not str.contains(signalSecret, ",") and not str.contains(signalSecret, "=") and not str.contains(signalSecret, " ") and not str.contains(signalSecret, "\n") and not str.contains(signalSecret, "\r") and not str.contains(signalSecret, "\t")
bool routingReady = validLicense and validSymbol and validSecret
bool protectionReady = stopPips >= 0 and targetPips >= 0 and str.tonumber(stopText) == stopPips and str.tonumber(targetText) == targetPips
bool sizeReady = amount > 0 and str.tonumber(amountText) == amount and protectionReady and (not needsStop or stopPips > 0)
string entryFields = "," + volumeKey + "=" + amountText + (stopPips > 0 ? ",sl_pips=" + stopText : "") + (targetPips > 0 ? ",tp_pips=" + targetText : "")
string secretField = signalSecret == "" ? "" : ",secret=" + signalSecret
string buyMessage = licenseId + ",buy," + brokerSymbol + entryFields + secretField
string closeMessage = licenseId + ",closelong," + brokerSymbol + secretField
float ema = ta.ema(close, length)
bool crossedUp = ta.crossover(close, ema)
bool crossedDown = ta.crossunder(close, ema)
bool entryEvent = crossedUp and barstate.isconfirmed
bool closeEvent = crossedDown and barstate.isconfirmed
plot(ema, title = "EMA", color = color.blue, linewidth = 2)
plotshape(entryEvent, title = "Buy condition", style = shape.triangleup, location = location.belowbar, color = color.blue, size = size.small, text = "Buy")
plotshape(closeEvent, title = "Close-buy condition", style = shape.triangledown, location = location.abovebar, color = color.orange, size = size.small, text = "Close buy")
if enableSignals and routingReady
if entryEvent and sizeReady
alert(buyMessage, alert.freq_once_per_bar_close)
else if closeEvent
alert(closeMessage, alert.freq_once_per_bar_close)
// Closing does not depend on entry-size settings. This script has no broker-position feedback.
string displayLicense = licenseId == "" ? "LicenseID" : licenseId
string displaySymbol = brokerSymbol == "" ? "BrokerSymbol" : brokerSymbol
string hiddenSecret = signalSecret == "" ? "" : ",secret=[hidden]"
string buyPreview = displayLicense + ",buy," + displaySymbol + entryFields + hiddenSecret
string closePreview = displayLicense + ",closelong," + displaySymbol + hiddenSecret
string status = not enableSignals ? "SIGNAL ALERTS OFF" : not routingReady ? "BLOCKED: check destination / secret format" : not sizeReady ? "ENTRY BLOCKED · close signals remain enabled" : "ENABLED: future chart events can send messages"
var table preview = table.new(position.top_right, 1, 4, border_width = 1)
if barstate.islast
table.cell(preview, 0, 0, status, text_color = color.white, bgcolor = enableSignals ? color.rgb(125, 45, 35) : color.rgb(30, 64, 100), text_size = size.normal)
table.cell(preview, 0, 1, "BUY MESSAGE (wrapped)\n" + str.replace_all(buyPreview, ",", ",\n"), text_color = color.black, bgcolor = color.white, text_halign = text.align_left, text_size = size.normal)
table.cell(preview, 0, 2, "CLOSE-BUY MESSAGE (wrapped)\n" + str.replace_all(closePreview, ",", ",\n"), text_color = color.black, bgcolor = color.rgb(240, 245, 250), text_halign = text.align_left, text_size = size.normal)
table.cell(preview, 0, 3, "No broker-position feedback. Recreate alerts after changes.", text_color = color.black, bgcolor = color.rgb(255, 246, 214), text_size = size.normal)
2

Save and add it to the chart

Save the new file as My connection practice. Click Add to chart. Remove or hide an earlier course indicator if it makes the new labels difficult to identify.

Markers are visible while alerts are off? That is expected. The script can draw historical conditions without generating a running alert or sending messages.

What you should see

Pine practice: connect indicator appears with an EMA, Buy and Close buy markers, and a SIGNAL ALERTS OFF table.

The connected indicator draws Buy and Close buy condition markers over its EMA.
Enlarge screenshot
Buy (1) and Close buy (2) are distinct conditions. With message generation off, these chart markers still appear; they are not broker-fill evidence.

Buy (1) and Close buy (2) are distinct conditions. With message generation off, these chart markers still appear; they are not broker-fill evidence.

The connected indicator draws Buy and Close buy condition markers over its EMA.
Connected indicator preview shows SIGNAL ALERTS OFF with separate placeholder buy and close-buy messages.
Enlarge screenshot
The initial preview should say SIGNAL ALERTS OFF. LicenseID and BrokerSymbol are placeholders until you enter and review your own destination privately.

The initial preview should say SIGNAL ALERTS OFF. LicenseID and BrokerSymbol are placeholders until you enter and review your own destination privately.

Connected indicator preview shows SIGNAL ALERTS OFF with separate placeholder buy and close-buy messages.

Check the switch, not just the source default. Open Inputs and confirm Enable PineConnector messages is unchecked after loading. TradingView can retain values on an existing chart instance when source changes. The distinct label separates this control from the earlier text-only practice switch; your current Inputs are still what matters.

Confirmed chart event Message built
Close crosses above the EMA buy, with the chosen size and any stop/target fields.
Close crosses below the EMA closelong, to request closing matching buys.

This indicator does not open short positions. It also does not receive broker-position feedback: a marker tells you what its chart condition did, not whether a broker position exists.

3

Review Inputs while signal alerts remain off

Open the gear beside Pine practice: connect indicator, then Inputs. Keep Enable PineConnector messages unchecked.

Enter your demo License ID, Exact broker symbol, and required Signal secret privately. Choose the size, stop and target you reviewed in the previous lesson. Do not assume settings from another script were copied here.

What you should see

The buy and close-buy previews show the intended destination and symbol, with the size only on the entry.

Enable PineConnector messages is unchecked in the connected indicator Inputs.
Enlarge screenshot
Check the actual chart input: Enable PineConnector messages must be off while you prepare and review the destination and sizing. A source default alone does not confirm this state.

Check the actual chart input: Enable PineConnector messages must be off while you prepare and review the destination and sizing. A source default alone does not confirm this state.

Enable PineConnector messages is unchecked in the connected indicator Inputs.
Pine practice: connect indicator Inputs show its disabled message switch and blank License ID, broker symbol and optional secret fields.
Enlarge screenshot
Destination fields in the connected indicator: License ID (1), exact broker symbol (2), and optional signal secret (3). Enter and review your own details privately when the lesson asks.

Destination fields in the connected indicator: License ID (1), exact broker symbol (2), and optional signal secret (3). Enter and review your own details privately when the lesson asks.

Pine practice: connect indicator Inputs show its disabled message switch and blank License ID, broker symbol and optional secret fields.

Read both messages on the chart before continuing. A configured secret is masked only in the preview; it will be included in the actual alert message. Keep that message and its log private.

Still says LicenseID or BrokerSymbol? One of the destination inputs is blank. The size is different from your plan? Check which Volume method is selected and which value field it uses.

4

Enable the script's future signal events

Return to Inputs, check Enable PineConnector messages, then click Ok. Do this before creating the review alert so its saved copy contains the intended setting.

BLOCKED appears? Read the status. The script rejects empty or malformed routing fields and invalid entry sizing. Its basic checks do not verify account ownership, broker support or that a secret matches Portal.

What you should see

The chart table says ENABLED: future chart events can send messages.

If it says ENTRY BLOCKED · close signals remain enabled, correct the entry-size/stop combination. The script deliberately does not use entry-size validity to suppress an otherwise valid close message.

This course example accepts numeric License IDs and single-line symbol/secret values without spaces, commas, equals signs or tab characters. Numeric message values must fit within eight decimal places. These are the example’s format checks, not proof that an ID exists, a secret matches Portal or the broker permits the values. Do not silently change a real symbol or secret to make it pass; resolve an unsupported format before proceeding.

5

Choose the correct alert event

Open Create alert from the chart toolbar. Under Condition, choose Pine practice: connect indicator, then choose Any alert() function call.

Confirm that the alert’s interval matches your chart. A generic Crossing comparison is not the event used by this code.

What you should see

Condition selects Pine practice: connect indicator and Any alert() function call.

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
The connected indicator alert uses Any alert() function call and Same as chart 1 minute.
Enlarge screenshot
Choose the connected indicator (1), Any alert() function call (2), and the reviewed interval (3). These event settings alone do not verify the destination or enable message generation.

Choose the connected indicator (1), Any alert() function call (2), and the reviewed interval (3). These event settings alone do not verify the destination or enable message generation.

The connected indicator alert uses Any alert() function call and Same as chart 1 minute.
6

Keep notifications disconnected and name the alert

Open Notifications. Clear Webhook URL; leave the other notification options off for quiet practice. Click Apply.

Open Message, name the alert PC message review, then click Apply. The script supplies the message body; do not add a second PineConnector template here.

What you should see

The review alert has no webhook destination.

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
7

Create one review alert

Recheck the indicator, event, interval and Notifications: None, then click Create. In the right-hand Alerts panel, search for PC message review.

No alert slot is available? The alert was not created. Keep the live-message check incomplete; a chart preview cannot replace it.

What you should see

PC message review appears as Active in TradingView's Alerts list.

The picture below shows the same Alerts → Log controls from the earlier practice lesson. Your current alert is named PC message review.

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
8

Inspect a future message

Open Log. After a new confirmed crossing, find your review event and read its message. Historical markers do not generate past messages when you create an alert.

The first event may be a close-buy condition. In this disconnected exercise it is still useful for checking the message; it does not prove there was a buy position.

What you should see

The Log contains the actual message from a new confirmed Buy or Close buy event.

Check Expected
License ID and broker symbol Your reviewed destination values, without placeholders.
Buy event buy plus your explicit volume field and chosen protection fields.
Close-buy event closelong, with no entry-volume field.
Authentication Your configured secret= appears on both message types when required.
Duplicates One event from this alert for that confirmed crossing.

If no new crossing occurs, leave this check pending and pause the review alert when you finish observing. Do not repeatedly create replacement copies to make an event happen.

9

Finish the disconnected test

In the Alerts list, right-click PC message review and choose Pause. Confirm Stopped manually. Then uncheck Enable PineConnector messages in the chart indicator’s Inputs.

Changing the chart input alone does not stop an existing alert’s saved copy. Always check the alert list.

What you should see

The review alert is paused and the current chart script has signal alerts off.

Find the code that builds the close-buy message. Explain why it contains the authentication field but omits the lot size, stop and target fields.

Check your answer

Authentication is still required when it is enabled for the destination. closelong requests closing matching buys; it does not request a new position with a new size or targets. The entry-only fields therefore belong on the buy message.

Your completion check: both message definitions are correct, at least one future event has been inspected when available, and webhook delivery remained off. A TradingView log entry alone is not PineConnector or broker verification.