Skip to content
Docs
Open Portal
Copy manually

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

Build a PineConnector message

Build and inspect a trading instruction on your chart before connecting a webhook.

You will turn a chart event into a readable PineConnector instruction. First, build the message on your chart and check its parts. Connecting it comes later.

The previous lesson compared named alert conditions with alert(). This module returns to the alert() path, where Inputs and code build the message. Neither method is a proficiency level; choose the method that fits the script.

You need to be able to save a script and change its Inputs. Keep any earlier practice alerts paused. You can complete this lesson without a PineConnector account by leaving the destination fields blank.

1

Create a separate indicator

Open Pine on the chart’s right-hand toolbar. Open the script-name menu and choose Create new → Indicator.

What you should see

You have a new starter script, separate from your earlier EMA practice.

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
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

Click Copy below. In TradingView, click inside the starter code, select all with Cmd+A or Ctrl+A, and paste with Cmd+V or Ctrl+V.

Complete message-preview indicatorPine v6
TradingView → Pine Editor Pine Script
//@version=6
indicator("Pine practice: message preview", overlay = true)
// Keep this saved script private after entering your own connection details.
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)
// These starting numbers illustrate the fields; check your broker's permitted values.
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 formatReady = str.tonumber(amountText) == amount and str.tonumber(stopText) == stopPips and str.tonumber(targetText) == targetPips
bool needsStop = volumeMethod == "Cash loss at stop" or volumeMethod == "Balance loss at stop" or volumeMethod == "Equity loss at stop"
string destination = (licenseId == "" ? "LicenseID" : licenseId) + ","
string symbolText = brokerSymbol == "" ? "BrokerSymbol" : brokerSymbol
string entryFields = "," + volumeKey + "=" + amountText + (stopPips > 0 ? ",sl_pips=" + stopText : "") + (targetPips > 0 ? ",tp_pips=" + targetText : "")
string hiddenSecret = signalSecret == "" ? "" : ",secret=[hidden]"
string buyPreview = destination + "buy," + symbolText + entryFields + hiddenSecret
string closePreview = destination + "closelong," + symbolText + hiddenSecret
string checkText = not formatReady ? "Use values that fit within 8 decimal places." : needsStop and stopPips <= 0 ? "Add a positive stop for this loss-based size." : "Check destination, broker units and permitted size."
// Line breaks make the table readable. No alert() or order functions exist here.
var table preview = table.new(position.top_right, 1, 5, border_width = 1)
if barstate.islast
table.cell(preview, 0, 0, "PREVIEW ONLY · nothing sent", text_color = color.white, bgcolor = 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, checkText, text_color = color.black, bgcolor = color.rgb(255, 246, 214), text_size = size.normal)
table.cell(preview, 0, 4, "Chart: " + syminfo.ticker + " · Broker: " + symbolText, text_color = color.black, bgcolor = color.white, text_size = size.normal)
2

Save and add the preview

Save with Cmd+S or Ctrl+S. Name the new file My message practice, then use Add to chart.

Only code is visible? Saving a file does not add it to the chart. Use the triangle-shaped Add to chart control beside the script name.

What you should see

The chart displays a table headed PREVIEW ONLY · nothing sent.

The preview-only chart table shows separate buy and closelong messages with placeholder destinations.
Enlarge screenshot
Compare the buy message with its size and protection (1) and the separate close-buy message (2). Line breaks are for display; this preview sends nothing.

Compare the buy message with its size and protection (1) and the separate close-buy message (2). Line breaks are for display; this preview sends nothing.

The preview-only chart table shows separate buy and closelong messages with placeholder destinations.

The chart table shows each field on a separate line so you can read it. The commas remain visible. A PineConnector message itself is one comma-separated instruction; you will not paste this wrapped chart table into an alert.

The five parts of this example
Read only; this contains placeholders PineConnector Syntax
LicenseID,buy,BrokerSymbol,vol_lots=0.01,sl_pips=20,tp_pips=40
Part What it tells PineConnector
LicenseID Which connection group receives the instruction.
buy Request a buy entry.
BrokerSymbol Which instrument to trade on the receiving broker account.
vol_lots=0.01 Request 0.01 lots, if that volume is permitted.
sl_pips=20,tp_pips=40 Request the illustrated stop and target distances.

Pine Script builds the text. PineConnector Syntax is the format of that text. A correctly formed message is still only a request; it does not prove that a broker accepted an order. Message structure

3

Open the preview's Inputs

Hover over Pine practice: message preview in the chart’s indicator list. Click its Settings gear, then open Inputs.

Leave License ID, Exact broker symbol and Signal secret blank for the first exercise.

What you should see

You can see Destination and Size and protection settings.

The private destination inputs are blank: License ID, exact broker symbol and optional signal secret.
Enlarge screenshot
Destination fields: License ID (1), exact broker symbol (2), and optional signal secret (3). Enter real values privately only when the lesson asks. This picture contains no credentials.

Destination fields: License ID (1), exact broker symbol (2), and optional signal secret (3). Enter real values privately only when the lesson asks. This picture contains no credentials.

The private destination inputs are blank: License ID, exact broker symbol and optional signal secret.

Blank destination fields produce the visible placeholders LicenseID and BrokerSymbol. That is expected in this preview. They are not valid values for a connected trading alert.

4

Find the receiving License ID

If you have a PineConnector connection, open Portal → Connections. Find the License ID used by your intended demo account and inspect the accounts listed beneath it.

Copy that License ID into the preview indicator’s License ID input. Do not use the broker account login or password.

No connection yet? Leave the input blank. You can finish the preview exercise and return to connection setup before the demo lesson.

What you should see

You can identify every account that would receive a message addressed to that ID.

Portal Connections with License ID groups on the left and a selected demo account on the right; identifiers hidden
Existing redacted Portal example. Read your own License ID group and its accounts; the hidden values here cannot be copied.
Existing redacted Portal example. Read your own License ID group and its accounts; the hidden values here cannot be copied.Open original
Portal Connections with License ID groups on the left and a selected demo account on the right; identifiers hidden

One ID can reach several accounts. A demo account beside a live account in the same group is not an isolated demo destination. Resolve the account selection before enabling delivery. License IDs and connections

5

Find the exact broker symbol

Open the intended broker account in its supported MT5 app or terminal. On desktop MT5, press Ctrl+U to open Symbols and read the Symbol column.

Put that exact name in Exact broker symbol. For example, a broker may use EURUSD.i rather than EURUSD. This example does not tell you which name your broker uses.

What you should see

The message identifies the broker instrument, including its complete spelling and suffix.

Desktop MetaTrader Symbols window showing where to read the broker's Symbol column
Existing desktop MT5 reference image. Find the symbol on your own demo account; mobile and web layouts differ.
Existing desktop MT5 reference image. Find the symbol on your own demo account; mobile and web layouts differ.Open original
Desktop MetaTrader Symbols window showing where to read the broker's Symbol column

The TradingView chart ticker and broker order symbol are separate. This script deliberately asks you for the broker name instead of assuming that syminfo.ticker is correct. If you already use Symbol Mapping or EA Prefix / Suffix, review the final symbol path before adding another transformation.

6

Check both preview messages

Click Ok to close Inputs. Read the chart table from top to bottom. The buy message contains size, stop and target fields. The close-buy message uses closelong and does not contain entry-size fields.

If Signal Authentication is already enabled for this destination, enter the matching secret privately in TradingView. The table shows secret=[hidden]; this display cannot verify that you entered the correct secret.

What you should see

The buy and close-buy messages use the same intended destination and broker symbol.

Keep your saved script, Inputs and screenshots private once they contain your connection details. The downloadable course file contains blank values; entering a secret in TradingView does not change that public download.

In this preview-only script, enter EURUSD.example as the broker symbol, then click Ok. Do both message previews change? Does the chart ticker change?

Check your answer

Both messages should now contain EURUSD.example. The chart ticker stays the same because you changed the message destination, not the chart. This invented example symbol is for the exercise only. Restore your verified broker symbol, or leave the field blank, before continuing.

Before you move on: explain the difference between License ID, broker login and broker symbol without looking at the table. Then continue to the size and protection lesson before creating a connected alert.