TradingView Syntax Guide

This guide is to ensure your alert message is in compliance with PineConnector syntax/formatting. Incorrect formatting will result in your alerts not going through or executing not in line with your intent.


TradingView Alerts Syntax 

Component Description Example
LicenseID
(required parameter)
License ID is long string found in the intranet.
1234567890123
Symbol
(required parameter)
Symbol or asset you would like to enter/exit
(please refer to notes below)
EURUSD, GER30
sl= Price or pips from current market price
(toggle on EA)
sl=1.2012 or sl=25
tp=
Price or pips from current market price
(toggle on EA)
tp=1.2022 or sl=50
risk=
(required parameter)
Lot size/Volume based on alert message or percentage of balance
(toggle on EA)
risk=0.05 or risk=2
price=
(required parameter for pending orders)
To put pending order at the stated price price=155 or risk=1.158
Market Order Commands
buy 
Direction of your trade
buy
sell
Direction of your trade
sell
closelong  To close the full long position of that symbol  ID,closelong,EURUSD
closeshort
To close the full short position of that symbol 
ID,closeshort,GBPJPY
Pending Order Commands
buystop
Place Buy Stop order above current market price
ID,buystop,USOIL,
price=75,sl=70
buylimit
Place Buy Limit order below current market price
ID,buylimit,USOIL,
price=65,sl=60
sellstop
Place Sell Stop order above current market price
ID,sellstop,USOIL,
price=75,sl=80
selllimit
Place Sell Limit order above current market price
ID,selllimit,USOIL,
price=65,sl=70
cancellong
cancels all long orders (buystop and buylimit) for the accompanying symbol
ID,cancellong,NAS100
cancelshort
cancels all short orders (sellstop and selllimit) for the accompanying symbol
ID,cancelshort,GBPJPY
Breakeven and Trailing Commands
betrigger=

Breakeven will be activated after a trade gains this number of pips beyond opening price.

*Ensure that value is minimally the broker's stops level in pips.

betrigger=30
beoffset=

Offset from the entry price. 0 means the SL will be placed exactly at entry price while 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades. This is the amount of pips you'd like to protect. 

*Ensure that beoffset<bettrigger

beoffset=5
trailtrig=

Trailing stop-loss will be activated after a trade gains this number of pips. 

If your trailtrig=0, price will have to minimally move the bid-ask spread to begin.

To begin instantaneously, without the need to move the bid-ask spread, you may use trailtrig<0. (i.e. trialtrig=-10)

trailtrig=15
traildist= Distance of the trailing stop-loss from current price. SL will be opened at traildist, after trailtrig is met, even if you do not have a SL placed.  traildist=10
trailstep= Moves trailing stop-loss once price moves favourable by a specified number of pips. trailstep=12 

Trailing Scenarios and Settings

 Scenario Recommended Trail Settings 
  • Trailing to start immediately
  • SL to be placed 10 pips from current price
  • SL to be moved every 1 pip of favorable movement
  • trailtrig=-10 (negative 10)
  • traildist=10
  • trailstep=1
  • Trailing to begin when price moves favorably by 8 pips
  • SL to be placed 9 pips from current price
  • SL to be moved every 5 pips of favorable movement
  • trailtrig=8
  • traildist=9
  • triailstep=5
Note: Values are typically in pips. When trading non-FX, such as the US100, using a value of 10 may mean 1 point in the index. Do test it first.

Sample Combined Syntax:

 Sample Syntax Interpretation
1234567890123,buy,AUDUSD,risk=0.01
Enter a long AUDUSD trade with 0.01 position size
  • EA Settings
    • Volume type = Specified Volume
1234567890123,sell,GBPJPY,sl=50,tp=150,risk=1

Enter a short 1 volume GBPJPY trade with SL and TP being 50 and 150 pips from current price. 

  • EA Settings
    • Target type = TP & SL based on pips
    • Volume type = Specified Volume
1234567890123,closelong,GBPUSD

Closes the all GBPUSD long trades

  • EA Settings
    • N/A
1234567890123,buy,EURUSD,sl=1.20,risk=1, trailtrig=15,traildist=10,trailstep=12

Going long EURUSD with initial SL at 1.20 risking 1% of account balance. Trailing stop to activate when price moves favorably by 15 pips. Every 12 pips move in favor of direction, the stop-loss will move to 10 pips from current price.

  • EA Settings
    • Target type = TP & SL based on price
    • Volume type = Percentage of balance
1234567890123,buy,EURCAD,sl=100,risk=5, betrigger=30,beoffset=5

Going long EURUSD with initial SL at 100 pips away, risking 5 volumes. SL will be moved to (entry price + 5 pips) when price has moved favorably by 30 pips.

  • EA Settings
    • Target type = TP & SL based on pips
    • Volume type = Specified volume

 

1234567890123,selllimit,EURUSD,price=1.2340,sl=10,risk=1

Place a sell limit on EURUSD at price of 1.2340 with a 10 pips stop-loss. Lot size/Volume of 1.

  • EA Settings
    • Target type = TP & SL based on pips
    • Volume type = Specified volume

 

1234567890123,cancellong,EURUSD

Cancel all long pending orders (buystop and buylimit) for EURUSD

  • EA Settings
    • NA

note: syntax commands are case-sensitive 


Ensure that your symbol is enabled (in yellow) and matches your symbol list.

Hold “Ctrl+U” to open the symbol list.
    MetaTrader 4
    MetaTrader 5
    Screenshot 2021-02-03 at 10.16.02 AM.png
    To copy the exact Symbol on the left column. i.e. “BTCEUR, BTCCNH..”
    Ensure the symbol is lit in yellow and not grey like the others. To change the colour, double click the symbol.
    Your broker might add a “$”, “#”, “Cash”, “m” before or after the main symbol name.
    Copy completely based on your symbol list.

    Important note:

     Components Remarks Example
    SL, TP, BE, Trailing Settings cannot be too tight. Refer to your symbol information in the symbol list under "Stops Level"
    1 pip from current price
    Tick Size Targets have to comply with symbol's tick size. Refer to "Tick Size"
    UK100 CFDs with a tick size of 0.5. Your target ending with 0.3 will be rejected.
    Volume Minimum volume should be met. Refer to "Minimal Volume" 0.1 minimum volume. Trade with volume or increments of 0.01 will be rejected.
     

    Related Links