Syntax for MT4/5
Syntax is the set of rules for constructing proper alert messages for sending to MT4/5.
A message is constructed by fields. A field is a parameter-value pair connected by "=". Fields are separated by ",". You can put no space or a few spaces after "," to make message clear to read.
Every message must have a token field which is the master token, you can get your master token on your TradingRouter Dashboard
Here are some syntax examples:
- token=master19dd529542d4b79d2bc4,signal=buy,symbol=EURUSD,risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=sell,symbol=EURUSD, risk_lots=0.1, sl_pips=100
- token=master19dd529542d4b79d2bc4,signal=closelong, symbol=EURUSD
Market Orders
Syntax for market orders such as buy and sell
buy
Place a buy order at the market price. Usually this order will be filled immediately.
- long
- bull
- bullish
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_pct_bal_loss=3, sl_pips=100
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURJPY, risk_cncy_amt=200, sl_pct=3
sell
Place a sell order at the market price. Usually this order will be filled immediately.
- short
- bear
- bearish
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=AUDUSD, risk_pct_bal_loss=3, sl_pips=100
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURJPY, risk_cncy_amt=200, sl_pct=3
slippage=
Set the maximum allowed slippage pips of the trade. This parameter is only used for market order
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, slippage=10
- token=master19dd529542d4b79d2bc4, signal=closeall, symbol=EURUSD, slippage=20
spread=
Enter the position only if the spread is equal or less than the specified pips. This parameter is only used for market order
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, spread=10 (note: create EURUSD long position only if the spread of EURUSD is equal or less than 10 pips.)
eaoff
Halts the TradingRouter EA. If the EA is halted, incoming signals will not be processed.
- token=master19dd529542d4b79d2bc4,signal=eaoff
eaon
Reactivates the TradingRouter EA from halt.
- token=master19dd529542d4b79d2bc4,signal=eaon
close all
Close all positions and delete all pending orders, regardless of symbol
If Magic Restriction is On, only the positions and orders created by TradingRouter EA will be closed and deleted. If Magic Restriction is Off, all positions and orders (including positions and orders created manually or by other EAs) will be closed and deleted.
This command will only work if symbol= is the same symbol where TradingRouter EA is running on. If TradingRouter EA is running on EURUSD, then you should set symbol=EURUSD
- token=master19dd529542d4b79d2bc4,signal=closeall,symbol=EURUSD (note: if TradingRouter is running on EURUSD chart, then all positions and pending orders will be closed and deleted.)
closealleaoff
Close all positions and delete all pending orders, regardless of symbol, then halts the TradingRouter EA. If the EA is halted, incoming signals will not be processed.
This command will only work if symbol= is the same symbol where TradingRouter EA is running on. If TradingRouter EA is running on EURUSD, then you should set symbol=EURUSD
- token=master19dd529542d4b79d2bc4,signal=closealleaoff,symbol=EURUSD (note: if TradingRouter is running on EURUSD chart, then all positions and pending orders will be closed and deleted.)
closelong
Close all long positions of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closelong,symbol=EURUSD
closeshort
Close all short positions of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closeshort, symbol=EURUSD
closelongbuy
Close all long positions of the specified symbol and open a new long position of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, risk_lots=0.5
closelongsell
Close all long positions of the specified symbol and open a new short position of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, risk_lots=0.5
closeshortbuy
Close all short positions of the specified symbol and open a new long position of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, risk_lots=0.5
closeshortsell
Close all short positions of the specified symbol and open a new short position of the specified symbol.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, risk_lots=0.5
newsltplong
Modify the stop loss and take profit of the long positions
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only positions of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the position's current price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the position's current price
If the Stop Loss Parameter is missing in this command, then positions' stop loss will not change
If the Take Profit Parameter is missing in this command, then positions' take profit will not change
If you use sl=0 in this command, the stop loss of all affected positions are set to their open prcie. So sl=0 means breakeven feature. Breakeven only works when a position is in profit. If a position is not in profit, then the stop loss is unchanged and you will get invalid stops error in the MT4/5 log.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltplong, symbol=EURUSD, sl_pips = 100 (note: all EURUSD long positions' stop loss is set 100 pips below current price)
- token=master19dd529542d4b79d2bc4,signal=newsltplong, sl_pips = 100 (note: all long positions' stop loss is set 100 pips below current price)
- token=master19dd529542d4b79d2bc4,signal=newsltplong, tp_pips = 100 (note: all long positions' take profit is set 100 pips above current price)
- token=master19dd529542d4b79d2bc4,signal=newsltplong, tp_price = 1.367 (note: all long positions' take profit is set to 1.367. This parameter is not recommended because 1.367 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltplong, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD long positions' stop loss is set 100 pips below current price, and take profit is set 1% above current price)
- token=master19dd529542d4b79d2bc4,signal=newsltplong, sl= 0 (note: all long positions' stop loss is set to open price, hence it is breakeven)
newsltpshort
Modify the stop loss and take profit of the short positions
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only positions of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the position's current price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the position's current price
If the Stop Loss Parameter is missing in this command, then positions' stop loss will not change
If the Take Profit Parameter is missing in this command, then positions' take profit will not change
If you use sl=0 in this command, the stop loss of all affected positions are set to their open prcie. So sl=0 means breakeven feature. Breakeven only works when a position is in profit. If a position is not in profit, then the stop loss is unchanged and you will get invalid stops error in the MT4/5 log.
If Magic Restriction is On, only the positions created by TradingRouter EA will be closed. If Magic Restriction is Off, all positions (including positions created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, symbol=EURUSD, sl_pips = 100 (note: all EURUSD short positions' stop loss is set 100 pips below current price)
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, sl_pips = 100 (note: all short positions' stop loss is set 100 pips below current price)
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, tp_pips = 100 (note: all short positions' take profit is set 100 pips above current price)
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, tp_price = 1.367 (note: all short positions' take profit is set to 1.367. This parameter is not recommended because 1.367 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD short positions' stop loss is set 100 pips below current price, and take profit is set 1% above current price)
- token=master19dd529542d4b79d2bc4,signal=newsltpshort, sl= 0 (note: all short positions' stop loss is set to open price, hence it is breakeven)
closelongpct
Close a percentage of long positions (based on your initial volume) of the specific symbol,
The percentage is set at Partial Close Percentage of your TradingRouter EA
If you set Partial Close Percentage to 50, when the closelongpct message comes, 50% of the initial volume will be closed
If you set Partial Close Percentage to 30, when the closelongpct message comes, 50% of the initial volume will be closed
You can set any number not greater than 100
- token=master19dd529542d4b79d2bc4,signal=buy, symbol=EURUSD, risk_lots=1 (note: 1 lot of EURUSD long position is created. Initial volume is 1 lot.)
- token=master19dd529542d4b79d2bc4,signal=closelongpct, symbol=EURUSD (note: 0.3 lot of EURUSD long position is closed )
- token=master19dd529542d4b79d2bc4,signal=closelongpct, symbol=EURUSD (note: 0.3 lot of EURUSD long position is closed )
- token=master19dd529542d4b79d2bc4,signal=closelongpct, symbol=EURUSD (note: 0.3 lot of EURUSD long position is closed )
- token=master19dd529542d4b79d2bc4,signal=closelongpct, symbol=EURUSD (note: final 0.1 lot of EURUSD long position is closed )
closeshortpct
Close a percentage of short positions (based on your initial volume) of the specific symbol,
The percentage is set at Partial Close Percentage of your TradingRouter EA
If you set Partial Close Percentage to 50, when the closeshortpct message comes, 50% of the initial volume will be closed
If you set Partial Close Percentage to 30, when the closeshortpct message comes, 50% of the initial volume will be closed
You can set any number not greater than 100
- token=master19dd529542d4b79d2bc4,signal=sell, symbol=EURUSD, risk_lots=1 (note: 1 lot of EURUSD short position is created. Initial volume is 1 lot.)
- token=master19dd529542d4b79d2bc4,signal=closeshortpct, symbol=EURUSD (note: 0.3 lot of EURUSD short position is closed )
- token=master19dd529542d4b79d2bc4,signal=closeshortpct, symbol=EURUSD (note: 0.3 lot of EURUSD short position is closed )
- token=master19dd529542d4b79d2bc4,signal=closeshortpct, symbol=EURUSD (note: 0.3 lot of EURUSD short position is closed )
- token=master19dd529542d4b79d2bc4,signal=closeshortpct, symbol=EURUSD (note: final 0.1 lot of EURUSD short position is closed )
closelongvol
Close long positions up to the indicated volume for the specific symbol.
symbol= and risk= are required parameters.
- token=master19dd529542d4b79d2bc4,signal=closelongvol, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD long position)
closeshortvol
Close short positions up to the indicated volume for the specific symbol.
symbol= and risk= are required parameters.
- token=master19dd529542d4b79d2bc4,signal=closeshortvol, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD short position)
Pending Orders
Syntax for pending orders such as buy limit, sell limit, buy stop and sell stop
buylimit
Place a buy limit order below the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
- Stop Loss Parameter is optional. But it is required if your Risk Parameter is risk_cncy_amt= or risk_pct_bal_loss=
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price_exact=1.023, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=AUDUSD, price_pct=1, risk_cncy_amt=200, sl_pips=100
selllimit
Place a sell limit order above the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
- Stop Loss Parameter is optional. But it is required if your Risk Parameter is risk_cncy_amt= or risk_pct_bal_loss=
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, price_exact=1.231, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=AUDUSD, price_pct=1, risk_cncy_amt=200, sl_pips=100
buystop
Place a buy stop order above the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
- Stop Loss Parameter is optional. But it is required if your Risk Parameter is risk_cncy_amt= or risk_pct_bal_loss=
- token=master19dd529542d4b79d2bc4, signal=buystop, symbol=EURUSD, price_exact=1.231, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=buystop, symbol=AUDUSD, price_pct=1, risk_cncy_amt=200, sl_pips=100
sellstop
Place a sell stop order below the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
- Stop Loss Parameter is optional. But it is required if your Risk Parameter is risk_cncy_amt= or risk_pct_bal_loss=
- token=master19dd529542d4b79d2bc4, signal=sellstop, symbol=EURUSD, price_exact=1.0123, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=sellstop, symbol=AUDUSD, price_pct=1, risk_cncy_amt=200, sl_pips=100
Price Parameter (for Pending Order)
Price parameter is used to determine the entry price of pending order. It has the following 4 parameters
- price_pips=
- price_pct=
- price_exact=
- price=
These 4 parameters has priorities: price_pips= > price_pct= > price_exact= > price=
You can only put one of the 4 price parameters in your message. If you put more than one price parameters in the message, the highest priority paramter in the message will be used. For example if you put price_pct= and price= in the message, only price_pct= will be used because price_pct= has higher priority than price= and price_pct= is the highest priority parameter in your message.
1. price_pips=
price_pips= set the entry price to some pips away from current market price
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price_pips=300, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 300 below current market price )
- token=master19dd529542d4b79d2bc4, signal=buystop, symbol=EURUSD, price_pips=200, sl_pips=100, risk_lots=0.2 (note: create a buystop order for 0.2 lot of EURUSD, the entry price is 200 above current market price, the stop loss is 100 pips )
2. price_pct=
price_pct= set the entry price to some percentage away from current market price
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price_pct=2, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 2% below current market price )
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, price_pct=3, sl_pips=100, risk_lots=0.2 (note: create a selllimit order for 0.2 lot of EURUSD, the entry price is 3% above current market price, the stop loss is 100 pips )
3. price_exact=
price_exact= set the entry price to a specific price
Note: This parameter is not recommended because the entry price may be invalid due to the discrepancy in quotes between TradingView and MT5. For example, your quote in Tradingview is $10000, but the quote at MT5 is $9998, if you make a buylimit order and set price_exact=9999, the entry price is above current market price and is invalid for buylimit order at MT5.
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price_exact=1.0012, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 1.0012 )
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, price_exact=1.2342, sl_pips=100, risk_lots=0.2 (note: create a selllimit order for 0.2 lot of EURUSD, the entry price is 1.2342, the stop loss is 100 pips )
4. price=
price= set the entry price of pending order according to the "Pending Order Entry Price Type(price=)" input in TradingRouter EA
There are 3 choices for "Pending Order Entry Price Type(price=)": "Pips from Current Market Price", "Percentage from Current Market Price", "Exact price"
If you choose "Pips from Current Market Price", price= set entry price to some pips away from current market price.
If you choose "Percentage from Current Market Price", price= set entry price to some percentage away from current market price.
If you choose "Exact price", price= set entry price to a specific price
Note: The choice "Exact price" is not recommended because the entry price may be invalid due to the discrepancy in quotes between TradingView and MT5. For example, your quote in Tradingview is $10000, but the quote at MT5 is $9998, if you make a buylimit order and set price_exact=9999, the entry price is above current market price and is invalid for buylimit order at MT5.
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price=300, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 300 below current market price )
- token=master19dd529542d4b79d2bc4, signal=buystop, symbol=EURUSD, price=200, sl_pips=100, risk_lots=0.2 (note: create a buystop order for 0.2 lot of EURUSD, the entry price is 200 above current market price, the stop loss is 100 pips )
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price=2, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 2% below current market price )
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, price=3, sl_pips=100, risk_lots=0.2 (note: create a selllimit order for 0.2 lot of EURUSD, the entry price is 3% above current market price, the stop loss is 100 pips )
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, price=1.0012, risk_lots=0.1 (note: create a buylimit order for 0.1 lot of EURUSD, the entry price is 1.0012 )
- token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, price=1.2342, sl_pips=100, risk_lots=0.2 (note: create a selllimit order for 0.2 lot of EURUSD, the entry price is 1.2342, the stop loss is 100 pips )
cancellong
delete all buylimit and buystop pending orders of the specified symbol.
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancellong,symbol=EURUSD
cancelshort
delete all selllimit and sellstop pending orders of the specified symbol.
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancelshort,symbol=EURUSD
cancellongbuylimit
delete all buylimit and buystop pending orders of the specified symbol and place a buy limit order below the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100
cancellongbuystop
delete all buylimit and buystop pending orders of the specified symbol and place a buy stop order above the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100
cancelshortselllimit
delete all sell limit and sell stop pending orders of the specified symbol and place a sell limit order above the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100
cancelshortsellstop
delete all sell limit and sell stop pending orders of the specified symbol and place a sell stop order below the current market price.
- symbol= is a required parameter, it must be in message
- Price Parameter is required
- Risk Parameter is required
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100
newsltpbuylimit
Modify the stop loss and take profit of buy limit pending order
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only orders of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the order's entry price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the order's entry price
If the Stop Loss Parameter is missing in this command, then orders' stop loss will not change
If the Take Profit Parameter< is missing in this command, then orders' take profit will not change
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, symbol=EURUSD, sl_pips = 100 (note: all EURUSD buy limit orders' stop loss is set 100 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, sl_pips = 200 (note: all buy limit orders' stop loss is set 200 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, tp_pips = 100 (note: all buy limit orders' take profit is set 100 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, tp_price = 1.6 (note: all buy limit orders' take profit is set to 1.6. This parameter is not recommended because 1.6 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD buy limit orders' stop loss is set 100 pips below entry price, and take profit is set 1% above entry price)
newsltpbuystop
Modify the stop loss and take profit of buy stop pending order
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only orders of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the order's entry price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the order's entry price
If the Stop Loss Parameter is missing in this command, then orders' stop loss will not change
If the Take Profit Parameter< is missing in this command, then orders' take profit will not change
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, symbol=EURUSD, sl_pips = 100 (note: all EURUSD buy stop orders' stop loss is set 100 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, sl_pips = 200 (note: all buy stop orders' stop loss is set 200 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, tp_pips = 100 (note: all buy stop orders' take profit is set 100 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, tp_price = 1.6 (note: all buy stop orders' take profit is set to 1.6. This parameter is not recommended because 1.6 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD buy stop orders' stop loss is set 100 pips below entry price, and take profit is set 1% above entry price)
newsltpselllimit
Modify the stop loss and take profit of sell limit pending order
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only orders of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the order's entry price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the order's entry price
If the Stop Loss Parameter is missing in this command, then orders' stop loss will not change
If the Take Profit Parameter< is missing in this command, then orders' take profit will not change
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, symbol=EURUSD, sl_pips = 100 (note: all EURUSD sell limit orders' stop loss is set 100 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, sl_pips = 200 (note: all sell limit orders' stop loss is set 200 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, tp_pips = 100 (note: all sell limit orders' take profit is set 100 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, tp_price = 0.6 (note: all sell limit orders' take profit is set to 1.6. This parameter is not recommended because 1.6 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD sell limit orders' stop loss is set 100 pips above entry price, and take profit is set 1% below entry price)
newsltpsellstop
Modify the stop loss and take profit of sell stop pending order
The new stop loss is set by Stop Loss Parameter and the new take profit is set by Take Profit Parameter
symbol= is optional. If symbol= is set, only orders of the specific symbol will be affected
If you use sl_pips= or sl_pct= ,the stop loss is calculated based on the order's entry price
If you use tp_pips= or tp_pct= ,the take profit is calculated based on the order's entry price
If the Stop Loss Parameter is missing in this command, then orders' stop loss will not change
If the Take Profit Parameter< is missing in this command, then orders' take profit will not change
If Magic Restriction is On, only the orders created by TradingRouter EA will be closed. If Magic Restriction is Off, all orders (including orders created manually or by other EAs) will be closed.
- token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, symbol=EURUSD, sl_pips = 100 (note: all EURUSD sell stop orders' stop loss is set 100 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, sl_pips = 200 (note: all sell stop orders' stop loss is set 200 pips above entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, tp_pips = 100 (note: all sell stop orders' take profit is set 100 pips below entry price)
- token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, tp_price = 0.6 (note: all sell stop orders' take profit is set to 1.6. This parameter is not recommended because 1.6 may not be a valid take profit for all symbols )
- token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, symbol=EURUSD, sl_pips = 100, tp_pct=1 (note: all EURUSD sell stop orders' stop loss is set 100 pips above entry price, and take profit is set 1% below entry price)
comment=
Add a string into the order's comment section.
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, comment=123
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, comment=123 abc,
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, comment=strategy one,
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, comment=strategy two,
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, comment=strategy/three
Stop Loss Parameter
Stop loss has the following 4 parameters
- sl_pips=
- sl_pct=
- sl_price=
- sl=
These 4 parameters has priorities: sl_pips= > sl_pct= > sl_price= > sl=
You can only put one of the 4 stop loss parameters in your message. If you put more than one stop loss parameters in the message, the highest priority paramter in the message will be used. For example if you put sl_pct= and sl= in the message, only sl_pct= will be used because sl_pct= has higher priority than sl= and sl_pct= is the highest priority parameter in your message.
If you choose "Set stop loss by message" for "SL Source" input in EA, the stop loss parameter in message will be used to determine the stop loss
If you choose "Set stop loss by EA, from the input below" for "SL Source" input in EA, the stop loss parameter in message will be ignored
1. sl_pips=
sl_pips= set the stop loss pips away from the open price of the order. If sl_pips=100, then the stop loss is 100 pips away from the open price of the order.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl_pips=100
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, sl_pips=150
Note: Usually brokers have requirement for minimum pips of stop loss, so if you set a small number of the pips, the order may not be filled and you will get "Invalid Stops" error in the log of Mt4/5.
2. sl_pct=
sl_pct= set the stop loss percentage away from the open price of the order. If sl_pips=1, then the stop loss is 1 percent away from the open price of the order. For example, if BTCUSD is at $20000, you buy with "sl_pct=0.1", then the stop loss is 0.1% away, at $19980.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl_pct=1
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, sl_pct=2
Note:
- sl_pct= should be less than 100.
- Usually brokers have requirement for minimum pips of stop loss, so if you set a small number for sl_pct, the order may not be filled and you will get "Invalid Stops" error in the log of Mt4/5.
3. sl_price=
sl_price= set exact price for stop loss. If sl_price=1.1234, then the stop loss set at 1.1234.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl_price=1.3012
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, sl_price=0.6045
Note: This parameter is not recommended because the stop loss may be invalid due to the discrepancy in quotes between TradingView and MT5, and also due to slippage. For example, your quote in Tradingview is $10000, but the quote at MT5 is $9999, if you make a market buy order and set sl_price=9999, the stop loss is invalid at MT5. Another example, your quote in Tradingview is $10000, and the quote at MT5 is also $10000, you make a market buy order and set sl_price=9999, but when the order is filled, the open price is $9998 due to slippage, then the stop loss is invalid.
4. sl=
sl= set the stop loss according to the "SL Type (sl=)" input in TradingRouter EA.
There are 3 choices for "SL Type (sl=)": pips, percentage, price
If you choose pips, the sl= means pips away from open price
If you choose percentage, the sl= means percentage away from open price
If you choose price, the sl= means exact price for stop loss
Take Profit Parameter
Take profit has the following 4 parameters
- tp_pips=
- tp_pct=
- tp_price=
- tp=
These 4 parameters has priorities: tp_pips= > tp_pct= > tp_price= > tp=
You can only put one of the 4 take profit parameters in your message. If you put more than one take profit parameters in the message, the highest priority paramter in the message will be used. For example if you put tp_pct= and tp= in the message, only tp_pct= will be used because tp_pct= has higher priority than tp= and tp_pct= is the highest priority parameter in your message.
If you choose "Set take profit by message" for "TP Source" input in EA, the take profit parameter in message will be used to determine the take profit
If you choose "Set take profit by EA, from the input below" for "TP Source" input in EA, the take profit parameter in message will be ignored
1. tp_pips=
tp_pips= set the take profit pips away from the open price of the order. If tp_pips=100, then the take profit is 100 pips away from the open price of the order.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp_pips=100
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, tp_pips=150
2. tp_pct=
tp_pct= set the take profit percentage away from the open price of the order. If tp_pips=1, then the take profit is 1 percent away from the open price of the order. For example, if BTCUSD is at $20000, you buy with "tp_pct=0.1", then the take profit is 0.1% away, at $20020.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp_pct=1
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, tp_pct=2
Note:
- tp_pct= should be less than 100 for sell order
3. tp_price=
tp_price= set exact price for take profit. If tp_price=1.1234, then the take profit is set at 1.1234.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp_price=1.0012
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, tp_price=0.9045
Note: This parameter is not recommended because the take profit may be invalid due to the discrepancy in quotes between TradingView and MT5, and also due to slippage. For example, your quote in Tradingview is $10000, but the quote at MT5 is $10001, if you make a market buy order and set tp_price=10001, the take profit is invalid at MT5. Another example, your quote in Tradingview is $10000, and the quote at MT5 is also $10000, you make a market buy order and set tp_price=10001, but when the order is filled, the open price is $10002 due to slippage, then the take profit is invalid.
4. tp=
tp= set the take profit according to the "TP Type (tp=)" input in TradingRouter EA.
There are 3 choices for "TP Type (tp=)": pips, percentage, price
If you choose pips, the tp= means pips away from open price
If you choose percentage, the tp= means percentage away from open price
If you choose price, the tp= means exact price for take profit
Risk Parameter
Risk parameter is used to determine the volume of the order. Risk has the following 5 parameters
- risk_lots=
- risk_cncy_amt=
- risk_pct_bal_loss=
- risk_pct_bal_mgn=
- risk=
These 5 parameters has priorities: risk_lots= > risk_cncy_amt= > risk_pct_bal_loss= > risk_pct_bal_mgn= > risk=
You can only put one of the 5 risk parameters in your message. If you put more than one risk parameters in the message, the highest priority paramter in the message will be used. For example if you put risk_pct_bal_loss= and risk= in the message, only risk_pct_bal_loss= will be used because risk_pct_bal_loss= has higher priority than risk= and risk_pct_bal_loss= is the highest priority parameter in your message.
If you choose "Set risk by message" for "Risk Source" input in EA, one of the 5 risk parameters must be in message
If you choose "Set risk by EA, from the input below" for "Risk Source" input in EA, you don't need put any risk parameter in message, and any risk parameter in the message will be ignored.
1. risk_lots=
risk_lots= sets the exact lots of the order
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2
2. risk_cncy_amt=
risk_cncy_amt= means the amount of currency that you will lose if your trade hits the SL
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_cncy_amt=150, sl_pips=100 (note: stop loss is 100 pips from open price. The volume is calculated by stop loss so that when the trade hits the stop loss, the trade will lose 150 amount of currency. If your base currency is USD, then $150 will be lost when the trade hits stop loss.)
3. risk_pct_bal_loss=
risk_pct_bal_loss= means the percentage of balance that you will lose if your trade hits the SL.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_pct_bal_loss=0.5, sl_pips=100 (note: stop loss is 100 pips from open price. The volume is calculated by stop loss so that when the trade hits the stop loss, the trade will lose 0.5% of your balance.)
4. risk_pct_bal_mgn=
risk_pct_bal_mgn= means the percentage of balance that the trade will increase the margin.
For example if risk_pct_bal_mgn=2 and your balance is $10000, then the trade will increase the margin by $10000 x 2% = $200
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_pct_bal_mgn=0.5 (note: If your balance is $10000, the 0.5% of your balance is $50. The volume is calculated so that the trade will increase your margin by $50. )
5. risk=
risk= set the risk according to the "Risk Type (risk=)" input in TradingRouter EA
There are 4 choices for "Risk Type (risk=)": "Lots", "Currency Amount", "Percentage of Balance, Loss", "Percentage of Balance, Margin"
If you choose "Lots", the risk= sets the exact lots of the order. It is the same as risk_lots=
If you choose "Currency Amount", the risk= means the amount of currency that you will lose if your trade hits the SL. It is the same as risk_cncy_amt=. You must set stop loss for the order because the volume is calculated according to stop loss
If you choose "Percentage of Balance, Loss", the risk= means the percentage of balance that you will lose if your trade hits the SL. It is the same as risk_pct_bal_loss=. You must set stop loss for the order because the volume is calculated according to stop loss
If you choose "Percentage of Balance, Margin", the risk= means the percentage of balance that the trade will increase the margin. It is the same as risk_pct_bal_mgn=.
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk=150, sl_pips=100 (note: stop loss is 100 pips from open price. The volume is calculated by stop loss so that when the trade hits the stop loss, the trade will lose 150 amount of currency. If your base currency is USD, then $150 will be lost when the trade hits stop loss.)
Expiration Parameter
Set expiration time for pending order. This parameter can only be used for pending order
There are two parameters: lifetime= and expiration=
MT5 uses both lifetime= and expiration=, while MT4 only uses expiration=
lifetime= has four possible values: GTC, DAY, SPEC, SPECDAY
For MT5
- If there is no lifetime= parameter in the message, the pending order will not expire.(good until cancel)
- If lifetime=GTC, the pending order will not expire.(good until cancel)
- If lifetime=DAY, the pending order will expire at the end of day
- If lifetime=SPEC, the expiration time of the pending order is specified by the expiration= parameter
- If lifetime=SPECDAY, the expiration time of the pending order is at the end of a specific day, this day is specified by the expiration= parameter.
The difference between SPEC and SPECDAY is that SPEC specifies the end time in terms of date and minutes, while SPECDAY specifies the end time to be end of day
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, risk_lots=0.1, price_pips=60, lifetime=SPEC, expiration=2023.2.19 07:08 (note: create a buy limit order of 0.1 lot EURUSD. The expiration time of this pending order is 2023.2.19 07:08)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD ,risk_lots=0.1, price_pips=60, lifetime=SPECDAY, expiration=2023.2.19 (note: create a buy limit order of 0.1 lot EURUSD. The expiration time of this pending order is the end of 2023.2.1)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD ,risk_lots=0.1, price_pips=60, lifetime=GTC (note: create a buy limit order of 0.1 lot EURUSD. The pending order will not expire, that is good until cancel)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD ,risk_lots=0.1, price_pips=60 (note: create a buy limit order of 0.1 lot EURUSD. As there is no lifetime parameter, the pending order will not expire, that is good until cancel)
For MT4
- MT4 only uses expiration= parameter to set expiration time. If expiration=0 or if there is no expiration= parameter, the pending order will not expire.(good until cancel)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, risk_lots=0.1, price_pips=60, expiration=2023.2.19 07:08 (note: create a buy limit order of 0.1 lot EURUSD. The expiration time of this pending order is 2023.2.19 07:08)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD ,risk_lots=0.1, price_pips=60, expiration=0 (note: create a buy limit order of 0.1 lot EURUSD. The pending order will not expire, that is good until cancel)
- token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD ,risk_lots=0.1, price_pips=60 (note: create a buy limit order of 0.1 lot EURUSD. As there is no expiration parameter, the pending order will not expire, that is good until cancel)
Breakeven Parameter
Automatically move the stop loss of positions to breakeven when betrigger= is satisfied
There are two parameters: betrigger= and beoffset=. All the two parameters are required in a command if you want Breakeven feature.
beoffset should be less than betrigger
Breakeven parameter are only used in market order command.
1. betrigger=
Breakeven will be activated after the position gains this number of pips. betrigger should be a positive number
2. beoffset=
Offset pips from entry price. For example, if beoffset=0, when breakeven is activated, stop loss will be placed at entry price. If beoffset=1, when breakeven is activated, stop loss will be placed at 1 pips above entry price for long position(or 1 pips below entry price for short position)
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, betrigger=100, beoffset=0 (note: create a long position for 0.1 lot of EURUSD, when the position gains 100 pips, stop loss is placed at open price)
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, betrigger=100, beoffset=20 (note: create a long position for 0.1 lot of EURUSD, when the position gains 100 pips, stop loss is placed at 20 pips above open price)
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=AUDUSD, risk_lots=0.1, sl_pips=100, betrigger=100, beoffset=20 (note: create a short position for 0.1 lot of EURUSD, when the position gains 100 pips, stop loss is placed at 20 pips below open price)
SL Trailing Parameter
Automatically moves SL with the direction in favour of the position (moves up for long position, and moves down for short position)
There are three parameters: trailtrig=, traildist= and trailstep=. All the three parameters are required in a command if you want SL Trailing feature.
1. trailtrig=
Stop loss trailing will be activated after a position gains this number of pips
2. traildist=
The distance of trailing stop loss from current price
3. trailstep=
Move trailing stop loss once price moves in favour by this number of pips
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, trailtrig=100, traildist=20, trailstep=5 (note: create a long position for 0.1 lot of EURUSD. When position gains 100 pips, stop loss is placed at 20 pips below current price. Then whenever price moves up 5 pips, stop loss is placed at 20 pips below current price. )
- token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, trailtrig=100, traildist=20, trailstep=5 (note: create a short position for 0.1 lot of EURUSD. When the position gains 100 pips, stop loss is placed 20 pips above current price. Then whenever price moves down 5 pips, stop loss is placed 20 pips above current price. )
Account Filter Parameter
This is only used for market order
Enter a position only if the account requirement is met. There are 5 parameters
- accfilter_bal=
- accfilter_eqt=
- accfilter_mgn=
- accfilter_mgn_pct=
- accfilter=
These 5 parameters has priorities: accfilter_bal= > accfilter_eqt= > accfilter_mgn= > accfilter_mgn_pct= > accfilter=
You can only put one of the 5 account filter parameters in your message. If you put more than one account filter parameters in the message, the highest priority paramter in the message will be used. For example if you put accfilter_eqt= and accfilter= in the message, only accfilter_eqt= will be used because accfilter_eqt= has higher priority than accfilter= and accfilter_eqt= is the highest priority parameter in your message.
1. accfilter_bal=
Signal will be processed only if your account balance is more than the specific value in accfilter_bal
If the signal is not processed due to your account balance is equal or less then accfilter_bal, you will MT4/5 log like this "Account balance is xxxxx not more than xxxxxx in message field accfilter_bal"
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter_bal=1234.5 (note: create a long position for 0.1 lot of EURUSD if your current account balance is greater then 1234.5 )
2. accfilter_eqt=
Signal will be processed only if your account equity is more than the specific value in accfilter_eqt
If the signal is not processed due to your account equity is equal or less then accfilter_eqt, you will MT4/5 log like this "Account equity is xxxxxx not more than xxxxx in message field accfilter_eqt"
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter_eqt=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account equity is greater then 5234.5 )
3. accfilter_mgn=
Signal will be processed only if your account free margin is more than the specific value in accfilter_mgn
If the signal is not processed due to your account free margin is equal or less then accfilter_mgn, you will MT4/5 log like this "Account free margin xxxxx not more than xxxxx in message field accfilter_mgn"
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter_mgn=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account free margin is greater then 5234.5 )
4. accfilter_mgn_pct=
Signal will be processed only if your account margin level is more than the specific value in accfilter_mgn_pct
If the signal is not processed due to your account margin level is equal or less then accfilter_mgn_pct, you will MT4/5 log like this "Account margin level is 3672.63 not more than 5234.50 in message field accfilter_mgn_pct"
- token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter_mgn_pct=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account margin level is greater then 5234.5 )
5. accfilter=
Filter will be determined by the "Account Filter Type (accfilter=)" input in TradingRouter EA
Therea are 4 choices for "Account Filter Type (accfilter=)": "Balance", "Equity", "Free Margin", and "Margin Percentage"
If you choose "Balance", Signal will be processed only if your account balance is more than the specific value in accfilter
If the signal is not processed due to your account balance is equal or less then accfilter, you will MT4/5 log like this "Account balance is xxxxxx not more than xxxxxx in message field accfilter"
If you choose "Equity", Signal will be processed only if your account equity is more than the specific value in accfilter
If the signal is not processed due to your account equity is equal or less then accfilter, you will MT4/5 log like this "Account equity is xxxxx not more than xxxxx in message field accfilter"
If you choose "Free Margin", Signal will be processed only if your account free margin is more than the specific value in accfilter
If the signal is not processed due to your account free margin is equal or less then accfilter, you will MT4/5 log like this "Account free margin is xxxxxx not more than xxxxxx in message field accfilter"
If you choose "Margin Percentage", Signal will be processed only if your account margin level is more than the specific value in accfilter
If the signal is not processed due to your account margin level is equal or less then accfilter, you will MT4/5 log like this "Account margin level is xxxxxx not more than xxxxxxin message field accfilter"