Skip to content

TradingView Alert Syntax: Format Messages for Automation

If your TradingView alert is firing but nothing happens in MetaTrader, the message format is usually the problem. PineConnector reads the alert body as an instruction and executes it. One wrong character and the signal gets rejected silently. 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.


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. If the log is empty after sending an alert, the message format is the issue.

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=. The EA executes exactly what the message says, regardless of what the EA settings are configured to.

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.

Start your 7-day trial for $14 at PineConnector and send your first automated trade today.


Leave a comment

Back To PiCo Blog

Great traders focus on strategy.
74,000+ of them automate the rest.

The alerts you already write become the orders you no longer have to place.

No credit card required
Full Advanced plan: Bridge, Analytics, Tasks, Notifications
Go live in under 30 minutes
Start 14-day free trial
Built on Microsoft Azure · Empowering traders since 2021