Skip to content

automated trading

TradingView Alert Syntax: Format Messages for Automation

PineConnector reads the alert body as an instruction and executes it. One wrong character and the signal gets rejected silently, which is one of several reasons a fired TradingView alert can produce nothing in MetaTrader. This guide covers the exact format required, the new explicit syntax introduced in 2025 and 2026, and every parameter that controls how trades are placed.


Before You Start: Does Your Script Actually Send a Usable Alert?

The syntax below only matters once your TradingView script can trigger an alert with the fields PineConnector needs. PineConnector's own guide to connecting a strategy names three ways this can work, and is explicit that none of them confirms compatibility on its own:

  • Strategy order-fill alerts. If you're automating a TradingView strategy (not an indicator), an "Order fills only" alert can fire on the strategy's simulated order fills. PineConnector's docs are direct that this "does not establish that the strategy's entries, exits and sizing map correctly to PineConnector": it confirms the alert fires, not that the message it sends is complete or correctly formed.
  • A script built with PineConnector-ready inputs. Some scripts expose fields such as a License ID, symbol, or separate long/short alert message inputs. A field named "License ID" is not, by itself, proof the script sends a working PineConnector message; check what the field actually populates in the alert text.
  • Named entry conditions in the Create Alert dialog. Open TradingView's alert dialog on the script and look at the Condition dropdown. An author who has added specific, named conditions, not a generic condition like "Crossing" alone, has usually built in alert support you can use, even if you cannot see or edit the script's source.

If none of these apply, for example the script only exposes generic conditions and no author-defined message, it is not set up to send a usable PineConnector alert as-is, closed-source or not. A plotted stop-loss or take-profit level on the chart is not automatically available as an alert parameter either. PineConnector's guide puts it plainly: "a picture of an entry on the chart cannot, by itself, create an alert." You still need an explicit message, built the way this guide describes below, referencing values the script's alert actually exposes. See PineConnector's guide to connecting your strategy for the full walkthrough of checking each path.


The Basic Structure

Every PineConnector alert message follows this fixed order:

LicenseID,Command,Symbol,Parameters

Three rules apply without exception:

  1. The order is fixed. License ID always comes first, then command, then symbol, then any additional parameters.
  2. Components must be separated by commas. Spaces around commas are acceptable but not required.
  3. Each message can only contain one License ID, one command, and one symbol.

A minimal working example:

60123456789,buy,EURUSD,vol_lots=0.1

If a signal does not appear in your MetaTrader terminal, check the Signals Log in your PineConnector portal first. Rejected signals (wrong syntax, incorrect License ID) do not appear in the log at all. PineConnector's own guidance is that a missing or incomplete log entry "is not a complete diagnosis" on its own: check whether an account is associated with the signal, then look at the processing and broker results. A missing entry can also mean the alert never reached PineConnector at all, a wrong or mismatched License ID, or a Signal Authentication secret that doesn't match, not only a malformed message. For the full stage-by-stage check, from the TradingView alert through delivery, PineConnector, the terminal and the broker, see this diagnosis guide.

If you prefer building your alert message visually before writing it manually, PineConnector has a Syntax Builder and Tester that lets you select your command, volume type, stop-loss, and take-profit through a form and generates the correct syntax automatically. It also includes a live tester to send a test signal before going live.


Explicit Syntax vs Legacy Syntax

PineConnector updated its syntax in December 2025 and January 2026, introducing explicit parameters that define exact units directly in the alert message. These are now the recommended approach for all new strategies.

Explicit syntax uses specific parameters like vol_lots=, sl_pips=, and tp_price=. Each explicit parameter takes priority over its corresponding EA setting (for example, vol_lots= is used as written regardless of the EA's Volume Type setting). It does not bypass other EA filters or broker rules: a spread filter (spread=), an account filter (accfilter=), and Magic Number restrictions on close/modify commands still apply on top of an explicit message.

Legacy syntax uses risk=, sl=, and tp=, which rely on the Volume Type and Target Type settings in your EA to interpret the values. Legacy syntax is fully supported and will continue to work, but it requires your EA settings to match your intent.

For new alerts, use explicit syntax. It is more precise, more portable across different setups, and easier to debug when something goes wrong.

One important note on MT4: in line with MetaQuotes' move to deprecate older MT4 versions, PineConnector ended active MT4 support on 1 October 2025. MT4 accounts can still connect, but bugs and issues will not receive active fixes. MT4 also only supports legacy syntax. Explicit parameters like vol_lots= and sl_pips= are not available on MT4. If you are still on MT4, migrating to MT5 is the recommended path before setting up new strategies.


Your License ID

Your License ID is the long number at the start of every alert message. It is 13 to 14 digits, for example 60123456789. Find it on the Connections page in the PineConnector portal.

The most common silent failure: leaving a placeholder like LicenseID in the message instead of replacing it with the actual number.


Market Order Commands

These commands place orders immediately at the current market price.

buy opens a long position. A volume parameter is required.

60123456789,buy,EURUSD,vol_lots=0.1

Valid alternatives for buy (case-insensitive): long, bull, bullish.

sell opens a short position. A volume parameter is required.

60123456789,sell,GBPJPY,vol_lots=0.1

Valid alternatives for sell: short, bear, bearish.


Volume Parameters

You must include exactly one volume parameter on every entry command. Choose the one that matches how you want to size your trades.

vol_lots= sets a fixed lot size. The EA executes exactly what is written.

60123456789,buy,EURUSD,vol_lots=0.1

vol_dollar= calculates lot size based on a cash amount you are willing to lose if the stop-loss is hit. Requires a stop-loss parameter.

60123456789,buy,EURUSD,vol_dollar=50,sl_pips=10

vol_pct_bal_loss= sizes the position so that a full stop-loss loss equals a percentage of your account balance. Requires a stop-loss parameter.

60123456789,sell,EURUSD,vol_pct_bal_loss=1,sl_pips=20

vol_pct_eq_loss= works the same way but calculates against account equity rather than balance.

60123456789,buy,US30,vol_pct_eq_loss=1,sl_pips=50

vol_pct_bal_margin= sizes the position based on a percentage of balance used as margin, without reference to a stop-loss.

60123456789,buy,EURUSD,vol_pct_bal_margin=5

Stop-Loss and Take-Profit Parameters

With explicit syntax, stop-loss and take-profit values use specific units rather than relying on EA settings.

sl_pips= / tp_pips= sets the distance in pips from the entry price. The EA defines 1 pip as 10 points.

60123456789,buy,EURUSD,vol_lots=0.1,sl_pips=20,tp_pips=40

sl_price= / tp_price= sets an absolute price level. Make sure the price is not too close to the current market price or the broker will reject the order.

60123456789,buy,EURUSD,vol_lots=0.1,sl_price=1.0800,tp_price=1.1200

sl_pct= / tp_pct= sets the distance as a percentage from entry. For a buy, sl_pct=1 places the stop-loss 1% below entry. For a sell, it places it 1% above.

60123456789,sell,BTCUSD,vol_lots=0.1,sl_pct=1,tp_pct=3

Closing Positions

Closing commands do not require a volume parameter.

closelong closes all open buy positions for the symbol. closeshort closes all open sell positions. closelongshort closes both.

60123456789,closelong,EURUSD
60123456789,closeshort,EURUSD
60123456789,closelongshort,EURUSD

closeall closes all open positions and pending orders across all symbols managed by the EA instance. The symbol in the command must match the chart the EA is running on.

60123456789,closeall,EURUSD

Pending Order Commands

Pending orders execute when price reaches a specified level. Every pending order requires both a volume parameter and an entry parameter.

The new explicit entry parameters introduced in January 2026 are:

entry_price= places the order at a specific price level.

60123456789,buylimit,EURUSD,entry_price=1.0750,vol_lots=1,sl_pips=30

entry_pips= places the order a set number of pips from the current market price. For stop orders this is worse than current price; for limit orders it is better.

60123456789,buystop,EURUSD,entry_pips=20,vol_lots=0.1

entry_pct= places the order a percentage distance from the current market price.

60123456789,selllimit,EURUSD,entry_pct=0.5,vol_lots=0.5

When using explicit entry parameters, stop-loss and take-profit distances are calculated from the pending entry price, not the current market price. Your risk to reward ratio is preserved exactly as intended.


Partial Position Closing

closelongpct and closeshortpct close a percentage of open volume. The percentage is configured in the EA settings. Adding sl=0 moves the stop-loss of remaining positions to breakeven.

60123456789,closelongpct,EURUSD
60123456789,closelongpct,EURUSD,sl=0

closelongvol and closeshortvol close a specific volume. risk= specifies the volume to close. Positions close on a first-in, first-out basis.

60123456789,closelongvol,EURUSD,risk=1.5

Modifying Open Positions

newsltplong and newsltpshort update the stop-loss and take-profit of open positions without closing them. They now support explicit parameters.

60123456789,newsltplong,EURUSD,sl_pips=10,tp_pips=30
60123456789,newsltplong,EURUSD,sl=0

Setting sl=0 moves the stop-loss to breakeven. The position must be in profit and the price must be far enough from entry to satisfy the broker's minimum stop distance.


Advanced Stop-Loss Management

These optional parameters are added to entry commands to automate stop-loss behavior.

Breakeven

betrigger= and beoffset= must both be present. Once the trade gains betrigger pips, the stop-loss moves automatically to beoffset pips from entry.

60123456789,buy,EURUSD,vol_lots=1,sl_pips=20,betrigger=10,beoffset=2

Pip Trailing

trailtrig=, traildist=, and trailstep= must all be present. Values are always in pips. Double-check the spelling: "trailing" not "trialing" is a common typo that silently breaks the feature.

60123456789,buy,EURUSD,vol_lots=1,trailtrig=12,traildist=8,trailstep=3

Trailing activates after 12 pips of profit. The stop-loss then trails 8 pips behind price and adjusts every 3 additional pips.

ATR Trailing

Pip trailing uses a fixed pip distance. ATR trailing uses a dynamic distance based on the Average True Range of the instrument. When volatility is high, the ATR grows and the stop gives the trade more room. When volatility is low, it stays tighter. This makes it better suited for instruments or sessions where volatility shifts significantly.

ATR is calculated from your broker's MetaTrader price data, not TradingView. Minor discrepancies between the two are expected.

atrtimeframe= and atrperiod= are mandatory. atrmultiplier= multiplies the ATR value to set the trailing distance (default 1). atrshift= determines which bar's ATR is used, with 0 being the most recent closed bar (default 0). atrtrigger= sets how many pips the trade must gain before trailing activates (default 0, meaning immediately).

60123456789,buy,EURUSD,vol_lots=1,sl_pips=10,atrtimeframe=60,atrperiod=14,atrmultiplier=2,atrtrigger=8

Trade Entry Filters

spread= blocks the entry if the current spread exceeds the specified pip value. Useful for avoiding entries during news events.

60123456789,buy,EURUSD,vol_lots=1,spread=2

accfilter= blocks the entry if a specified account metric falls below the threshold. The metric type (balance, equity, margin, free margin) is set in the EA.

60123456789,buy,EURUSD,vol_lots=1,accfilter=500

Combined Commands

When a new signal should replace an existing position, combined commands handle the close and open in one message. Short forms are accepted.

60123456789,closelongopenshort,EURUSD,vol_lots=1
60123456789,CL+OS,EURUSD,vol_lots=1

Full list of available short forms: CL+OL, CL+OS, CS+OL, CS+OS, CLS+OL, CLS+OS.


Common Syntax Mistakes

These are the errors that cause signals to be silently rejected most often.

Wrong component order: buy,LicenseID,EURUSD will not work. License ID must always be first.

Multiple commands in one message: LicenseID,buy,sell,EURUSD,vol_lots=1 is invalid. One command per message only.

Missing volume parameter on entry commands: LicenseID,buy,EURUSD without vol_lots= or another volume parameter will be rejected.

Mixing conflicting volume parameters: sending both vol_lots= and vol_dollar= in the same message will cause the EA to reject the signal.

Trailing parameter typo: trailling instead of trailing breaks the trailing stop silently.

Comment over 20 characters: the comment will default to blank without any error shown.


Full Syntax Reference

The complete documentation including all commands, parameters, and combined examples is at docs.pineconnector.com/syntax. If you want to build and test your alert message visually before adding it to a script, use the Syntax Builder and Tester. For connecting your first strategy end-to-end, the Low-Code Alert guide walks through adding alert messages to any Pine Script in a few steps.

Try Core for 7 days for $7 at PineConnector, with hosted MT5 through Edge included, and send your first automated trade today. After the trial, Core is $59/month unless you cancel.


Leave a comment

Back To PiCo Blog

Ready when your strategy is

You bring the strategy.We bring the infrastructure.

Connect TradingView to MetaTrader, choose where MT5 runs and put the full PineConnector workflow through its paces from your first month.

Strategy and trading decisions remain yours. The MT5 environment can be ours.

PineConnector Edge

Run the full PineConnector workflow.

$59/mo at launch

Core plan · 1 connection · 1 hosted MT5 environment

Try Core for $7

7 days of Core for $7, then $59/month at the launch price unless you cancel.