Syntax
Syntax refers to the set of rules that dictate the proper construction of an alert message.
- 60123456789,buy,AUDUSD,risk=0.1
- 60123456789,sell,GBPJPY,sl=50,risk=1
- 60123456789,closelong,GBPUSD
To see more Sample Combined Syntax and its interpretations, click here.
Alert Message Guidelines
To create PineConnector-compliant alert messages, please pay attention to the following guidelines. Failure to adhere to the syntax may result in the EA rejecting your signal.
- The alert message configured on TradingView is valid, as per the Syntax Guide.
- The selected EA Settings result in the intended behavior.
To learn how to send manual or test alerts, click here.
Keep in mind that rejected signals will not appear in the log.
Components
There are four components in alert messages, namely:
Component | Remarks |
License ID | This is a unique identifier found in the Licensing Dashboard.
It is a long value that usually starts with a 6 or 7, such as 70123456789. |
Commands | These are actions like "buy," "sell," etc.
Please note that commands do not have an equal (=) sign. |
Symbol | This refers to the asset or instrument to be traded. |
Others | These are additional components that use the equal (=) sign, such as "risk=". |
Structure
- The syntax must follow this order:
LicenseID, Command, Symbol, Others
- Components must be separated by commas (,)
- Each alert can only have one License ID, Command, and Symbol.
Acceptable PineConnector Syntax
1. LicenseID,Command,Symbol,Others (without spacing between commas)
2. LicenseID , Command , Symbol , Others (with spacing between commas)
Unacceptable PineConnector Syntax
1. Command,LicenseID,Symbol (incorrect order)
2. LicenseID,Command,Command (multiple Commands)
3. LicenseID,LicenseID,Command,Symbol (multiple LicenseIDs)
Market Orders
Commands and syntax for market orders such as buy and sell.
buy
Place a buy order at the market.
- long
- bull
- bullish
LicenseID,buy,EURUSD,risk=0.01
LicenseID,long,US30.Cash,risk=1
LicenseID,bullish,GBPJPY,risk=1
sell
Place a sell order at the market.
- short
- bear
- bearish
LicenseID,sell,EURUSD,risk=0.01
LicenseID,short,DAX30,risk=2
LicenseID,bear,GBPJPY,risk=1
risk=
Function depends on the “Volume Type” selected in the EA EA Options: Lots, Dollar Amount, Percentage of Balance (Lots) and Percentage of Balance (Loss).
LicenseID,buy,EURUSD,risk=0.01
LicenseID,sell,EURCAD,risk=2
sl=
Place stop-loss. Computation is based on the Target Type selected in the EA EA Options: Pips, Price and Percentage.
LicenseID,buy,EURUSD,risk=1,sl=10.5
tp=
Place take-profit. Computation is based on the Target Type selected in the EA EA Options: Pips, Price and Percentage.
LicenseID,buy,EURUSD,risk=1,tp=15
comment=
Add a string into the order’s comment section. Valid for entry commands only (buy, buylimit etc).
LicenseID,buy,EURUSD,risk=1,comment=Strategy 1
LicenseID,buy,EURUSD,risk=1,comment=Strategy 2
LicenseID,buy,EURUSD,risk=1,comment= 100 5/6
LicenseID,buy,EURUSD,risk=1,comment= Set=20
LicenseID,buy,EURUSD,risk=1,comment=12345678901234567890 (valid, within 20 charactes)
LicenseID,buy,EURUSD,risk=1,comment=123456789012345678901 (invalid, above 20 charactes)
eaoff
Halts the PineConnector EA. If the EA is halted, incoming signals will not be processed.
LicenseID,eaoff,eaoff
eaon
Reactivates the PineConnector EA from halt.
LicenseID,eaon,eaon
closeall
Close all positions and orders, regardless of symbol
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closeall,EURUSD
closealleaoff
Close all positions and orders, and off/halt the PineConnector EA.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closealleaoff,EURUSD
closelong
Close all buy positions of the specified symbol.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closelong,EURUSD
closeshort
Close all sell positions of the specified symbol.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closeshort,EURUSD
closelongshort
Close all buy and sell positions of the specified symbol.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closelongshort,EURUSD
closelongbuy
Close all buy positions and open a new buy.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closelongbuy,EURUSD,risk=1
closeshortsell
Close all sell positions and open a new sell.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closeshortsell,EURUSD,risk=1
newsltplong
Modify the stop-loss (SL) and take-profit (TP) of the buy positions. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltplong,EURUSD,sl=10
LicenseID,newsltplong,EURUSD,tp=20
LicenseID,newsltplong,EURUSD,sl=30,tp=60
LicenseID,newsltplong,EURUSD,sl=1.12345 (price)
LicenseID,newsltplong,EURUSD,sl=1,tp=2 (percentage)
LicenseID,newsltplong,EURUSD,sl=0 (breakeven)
Required Conditions
- Position is in profit
- Current market price is sufficiently far from the entry price
If either of the conditions are not met, sending in a “newsltplong” with sl=0 will result in the Error 130 on MT4 and Error 4756 (Invalid Price) on MT5.
newsltpshort
Modify the stop-loss (SL) and take-profit (TP) of the sell positions. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltpshort,EURUSD,sl=10
LicenseID,newsltpshort,EURUSD,tp=20
LicenseID,newsltpshort,EURUSD,sl=30,tp=60
LicenseID,newsltpshort,EURUSD,sl=1.12345 (price)
LicenseID,newsltpshort,EURUSD,sl=1,tp=2 (percentage)
LicenseID,newsltpshort,EURUSD,sl=0 (breakeven)
- Position is in profit
- Current market price is sufficiently far from the entry price
If either of the conditions are not met, sending in a “newsltpshort” with sl=0 will result in the Error 130 on MT4 and Error 4756 (Invalid Price) on MT5.
closelongpct
Close a percentage of buy positions (based on your initial volume), using your selected partial close percentage in the EA (25%, 34%, and 50%).
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closelongpct,EURUSD
closeshortpct
Close a percentage of sell positions (based on your initial volume), using your selected partial close percentage in the EA (25%, 34%, and 50%).
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closeshortpct,EURUSD
closelongvol
Close buy positions up to the indicated value. risk= is a required parameter.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closelongvol,EURUSD,risk=3
LicenseID,closelongvol,EURUSD,risk=0.5
- Position A: Buy 1 lot (opened first)
- Position B: Buy 2 lots (opened second)
- Position C: Buy 0.5 lots (opened last)
- Partial Closure Across Multiple Positions
- Command:
closelongvol with risk=2.8
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close 1.8 lots, leaving 0.2 lots remaining.
- Position C remains unaffected with 0.5 lots.
- Closing More Than the Total Volume
- Command:
closelongvol with risk=4
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close fully from 2 lots to 0 lots.
- Position C will close fully from 0.5 lots to 0 lots.
- Note: The total volume to close (4) exceeds the open positions (3.5), so all positions are closed.
- Closing Less Than the Smallest Position
- Command:
closelongvol with risk=0.4
- Result:
- Position A will close 0.4 lots, leaving 0.6 lots remaining.
- Position B remains unaffected with 2 lots.
- Position C remains unaffected with 0.5 lots.
- Closing Exactly the Total Volume of Positions
- Command:
closelongvol with risk=3.5
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close fully from 2 lots to 0 lots.
- Position C will close fully from 0.5 lots to 0 lots.
- Note: The total volume to close matches the sum of all open positions, resulting in complete closure of all positions.
closeshortvol
Close sell positions up to the indicated value. risk= is a required parameter.
This syntax will only close positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,closeshortvol,EURUSD,risk=3
LicenseID,closeshortvol,EURUSD,risk=0.5
Pending Orders
Commands and syntax for pending orders such as buy stop, buy limit, sell stop and sell limit.
pending=
Computing pending order entry price. EA Options: Pips, Specified Price, Percentage
LicenseID,buystop,EURUSD,pending=10,risk=1
buystop
Place buy stop above the current market price. pending= is a required parameter.
LicenseID,buystop,EURUSD,pending=10,risk=1
buylimit
Place buy limit below the current market price. pending= is a required parameter.
LicenseID,buylimit,EURUSD,pending=10,risk=1
sellstop
Place sell stop below the current market price. pending= is a required parameter.
LicenseID,sellstop,EURUSD,pending=10,risk=1
selllimit
Place sell limit above the current market price. pending= is a required parameter.
LicenseID,selllimit,EURUSD,pending=10,risk=1
cancellong
Cancels all long orders with the specified symbol.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancellong,EURUSD
cancelshort
Cancels all short orders with the specified symbol.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancelshort,EURUSD
cancellongbuystop
Cancels all long orders with the specified symbol and places a buystop order. risk= and pending= are required parameters.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancellongbuystop,EURUSD,risk=1,pending=10,sl=15,tp=20
cancellongbuylimit
Cancels all long orders with the specified symbol and places a buylimit order. risk= and pending= are required parameters.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancellongbuylimit,EURUSD,risk=1,pending=10,sl=15,tp=20
cancelshortsellstop
Cancels all short orders with the specified symbol and places a sellstop order. risk= and pending= are required parameters.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancelshortsellstop,EURUSD,risk=1,pending=10,sl=15,tp=20
cancelshortselllimit
Cancels all short orders with the specified symbol and places a selllimit order. risk= and pending= are required parameters.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,cancelshortselllimit,EURUSD,risk=1,pending=10,sl=15,tp=20
newsltpbuystop
Modify the stop-loss (SL) and take-profit (TP) of the buystop orders. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage orders opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltpbuystop,EURUSD,sl=10
LicenseID,newsltpbuystop,EURUSD,tp=20
LicenseID,newsltpbuystop,EURUSD,sl=30,tp=60
newsltpbuylimit
Modify the stop-loss (SL) and take-profit (TP) of the buylimit orders. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage orders opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
This syntax will only cancel positions opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltpbuylimit,EURUSD,sl=10
LicenseID,newsltpbuylimit,EURUSD,tp=20
LicenseID,newsltpbuylimit,EURUSD,sl=30,tp=60
newsltpsellstop
Modify the stop-loss (SL) and take-profit (TP) of the sellstop orders. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage orders opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltpsellstop,EURUSD,sl=10
LicenseID,newsltpsellstop,EURUSD,tp=20
LicenseID,newsltpsellstop,EURUSD,sl=30,tp=60
newsltpselllimit
Modify the stop-loss (SL) and take-profit (TP) of the selllimit orders. New SL and TP are computed based on your selected Target Type on the EA.
This syntax will only manage orders opened by the PineConnector EA - to remove this restriction, turn Magic Restriction off in the EA.
LicenseID,newsltpselllimit,EURUSD,sl=10
LicenseID,newsltpselllimit,EURUSD,tp=20
LicenseID,newsltpselllimit,EURUSD,sl=30,tp=60
Breakeven
The breakeven point is when your stop loss (SL) is set at your entry price, meaning if the SL is hit, there will be no losses.
newsltplong
or newsltpshort
with sl=0 to trigger the SL adjustment to breakeven at a later stage.- Automatically move the SL of the position to breakeven when betrigger= is satisfied
- Ensure that beoffset < betrigger
betrigger=
Breakeven will be activated after the position gains this number of pips. Ensure > 0
beoffset=
Offset from entry price. 0 means the SL will be placed exactly at entry price. 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.
LicenseID,buy,EURUSD,risk=1,sl=20,betrigger=10,beoffset=2
Ensure that the 2 parameters “betrigger=” and “beoffset=” are present in your syntax.
Pip Trailing
- Automatically moves SL with the direction of the trade (up for longs, and down for shorts)
- All trailing parameters are restricted to integers — floats will be rounded to the nearest integer
- Trailing computation will be based on pips, regardless of the Target Type selected
trailtrig=
Trailing stop-loss will be activated after a trade gains this number of pips.
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.
trailstep=
Moves trailing stop-loss once price moves to favourable by a specified number of pips.
LicenseID,buy,EURUSD,risk=1,trailtrig=12,traildist=8,trailstep=3
Ensure that the 3 parameters “trailtrig=”, “traildist=” and “trailstep=” are present in your syntax.
- With trailtrig=12, the first instance of trailing SL will be when price moves favourably for 12 pips (entry+12).
- The SL will be placed 8 pips lower at (entry+12-8).
- If you have a SL, the SL will be updated
- If you do not have a SL, a SL will be created for you
- With trailstep=3, the second instance of trailing SL is when price moves favourably for another 3 pips (entry+12+3).
- The SL will be placed at 8 pips lower at (entry+12+3-8).
- The third instance will be when price moves another 3 favourable pips (entry+12+3+3)
- The SL will be placed 8 pips lower at (entry+12+3+3-8), and so on.
You can use a negative 'trailtrig=' value to ensure immediate activation of the trailing feature. If you use 'trailtrig=0', the pip-trailing might only begin after the spread in pips.
For example, you could use : trailtrig=-10,traildist=12,trailstep=1' With this configuration, the Expert Advisor (EA) will start pip-trailing immediately. The Stop Loss (SL) will be adjusted every 10 pips from the market price, and the SL will be moved every 1 pip in case of favorable movement.
ATR Trailing
- Instead of your SL trailing based on pips, your SL trails based on the ATR computed
- Only atrtimeframe= and atrperiod= are mandatory — other parameters are optional
atrtimeframe=
ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. If stop loss not specified at the point of entry, a SL will be automatically added with the ATR values used.
Allowable timeframe values for MT4:
- 1 (1 minute),
- 5 (5 minutes),
- 15 (15 minutes),
- 30 (30 minutes),
- 60 (1 hour),
- 240 (4 hours),
- 1440 (1 day)
atrperiod=
ATR averaging period
atrmultiplier=
Multiple of ATR to utilise in the new SL computation. Default = 1
atrshift=
Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default: 0
atrtrigger=
Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default: 0 (instantaneous)
LicenseID,buy,EURUSD,risk=1,sl=10,
atrtimeframe=60,atrperiod=14,atrmultiplier=2,atrtrigger=8
Ensure that at the 2 parameters “atrtimeframe=” and “atrperiod=” are present in your syntax. Other components are optional where they will use the default values as stated above.
Filters
spread=
Enter the position only if the spread is equal or less than the specified value in pips.
LicenseID,buy,EURUSD,risk=1,spread=2
LicenseID,buy,EURUSD,risk=1,spread=1.22
accfilter=
Enter the position only if the account requirement is met. EA Options: Account Balance, Account Equity, Margin Percentage and Free Margin
LicenseID,buy,EURUSD,risk=1,accfilter=500
Miscellaneous
secret=
Include this parameter to authenticate the signal with a specific secure key.
You will only need to specify a secret key if you have Signal Authentication turned “On”.
LicenseID,buy,EURUSD,risk=1,secret=SECRETKEY
Sample Combined Syntax
In this section, we will explore some syntax possibilities which are compliant.
Market Orders (buy/sell)
Syntax | Interpretation |
60123456789,buy,AUDUSD,risk=0.01 | • Enters a long AUDUSD trade
• Opens a 0.01 position size (“lots” volume type) |
60123456789,sell,GBPJPY,sl=50,tp=150,risk=1 | |
60123456789,buy,EURUSD,risk=1,spread=3 | • Opens a buy EURUSD at the market if current spread is 3 or lower
• Opens a position with 1 volume (“lots” volume type)
• No SL or TP will be added |
60123456789,closelong,GBPUSD | • Closes the all GBPUSD long trades |
60123456789,newsltplong,EURUSD,sl=10,tp=30 |
With Pips or ATR Trailing, or Breakeven
Syntax | Interpretation |
60123456789,buy,EURUSD,sl=1.20,risk=1, trailtrig=15,traildist=10,trailstep=12 | • Opens a long EURUSD position
• Volume is dynamically computed which risks 1% of your account balance (“percentage of balance, loss” volume type)
• Initial SL at 1.20 (“price” target type)
• 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 |
60123456789,buy,EURUSD,sl=10,
atrtimeframe=60,atrperiod=14,atrmultiplier=2,atrtrigger=8,risk=1 | |
60123456789,buy,EURCAD,sl=100,risk=5,betrigger=30,beoffset=5 |
Pending Orders (buylimit, selllimit, buystop, sellstop)
Syntax | Interpretation |
60123456789,selllimit,EURUSD,price=1.2340,sl=10,risk=1 | |
60123456789,cancellong,EURUSD | • Cancels all long pending orders (buystop and buylimit) for EURUSD |
On this page
- Syntax
- Alert Message Guidelines
- Components
- Structure
- Market Orders
- buy
- sell
- risk=
- sl=
- tp=
- comment=
- eaoff
- eaon
- closeall
- closealleaoff
- closelong
- closeshort
- closelongshort
- closelongbuy
- closeshortsell
- newsltplong
- newsltpshort
- closelongpct
- closeshortpct
- closelongvol
- closeshortvol
- Pending Orders
- pending=
- buystop
- buylimit
- sellstop
- selllimit
- cancellong
- cancelshort
- cancellongbuystop
- cancellongbuylimit
- cancelshortsellstop
- cancelshortselllimit
- newsltpbuystop
- newsltpbuylimit
- newsltpsellstop
- newsltpselllimit
- Breakeven
- betrigger=
- beoffset=
- Pip Trailing
- trailtrig=
- traildist=
- trailstep=
- ATR Trailing
- atrtimeframe=
- atrperiod=
- atrmultiplier=
- atrshift=
- atrtrigger=
- Filters
- spread=
- accfilter=
- Miscellaneous
- secret=
- Sample Combined Syntax
- Market Orders (buy/sell)
- With Pips or ATR Trailing, or Breakeven
- Pending Orders (buylimit, selllimit, buystop, sellstop)
We have 3 open long positions, totaling 3.5 lots, arranged by the time they were opened:
- Position A: Buy 1 lot (opened first)
- Position B: Buy 2 lots (opened second)
- Position C: Buy 0.5 lots (opened last)
- Scenario A: Partial Closure Across Multiple Positions
- Command:
closelongvol with risk=2.8
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close 1.8 lots, leaving 0.2 lots remaining.
- Position C remains unaffected with 0.5 lots.
- Scenario B: Closing More Than the Total Volume
- Command:
closelongvol with risk=4
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close fully from 2 lots to 0 lots.
- Position C will close fully from 0.5 lots to 0 lots.
- Note: The total volume to close (4) exceeds the open positions (3.5), so all positions are closed.
- Scenario C: Closing Less Than the Smallest Position
- Command:
closelongvol with risk=0.4
- Result:
- Position A will close 0.4 lots, leaving 0.6 lots remaining.
- Position B remains unaffected with 2 lots.
- Position C remains unaffected with 0.5 lots.
- Scenario D: Closing Exactly the Total Volume of Positions
- Command:
closelongvol with risk=3.5
- Result:
- Position A will close fully from 1 lot to 0 lots.
- Position B will close fully from 2 lots to 0 lots.
- Position C will close fully from 0.5 lots to 0 lots.
- Note: The total volume to close matches the sum of all open positions, resulting in complete closure of all positions.