Trading Router

Syntax for MetaTrader 4/5




Syntax is the set of rules for constructing proper alert messages for sending alert from Tradingview to MT5 MT4.

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


Sample Syntax

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.

If you use the advanced trid= parameter feature, the position created by this buy command will have a trid. You can later identify this position by the trid.

Valid Alternatives (case-insensitive)
  • long
  • bull
  • bullish


  • symbol= is a required parameter, it must be in message

  • If you choose "Set risk by message" for "Risk Source" input in EA, one of the following parameter must be in message MT4/5 settings for getting buy order risk information from Tradingview alert message
    1. risk_lots=
    2. risk_cncy_amt=
    3. risk_pct_bal_loss=
    4. risk_pct_bal_mgn=
    5. risk=


buy examples
  • 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
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=buy_001, symbol=EURUSD, risk_lots=0.1 (note: create EURUSD a long position whose trid is buy_001)


sell

Place a sell order at the market price. Usually this order will be filled immediately.

If you use the advanced trid= parameter feature, the position created by this sell command will have a trid. You can later identify this position by the trid.

Valid Alternatives (case-insensitive)
  • short
  • bear
  • bearish


  • symbol= is a required parameter, it must be in message

  • If you choose "Set risk by message" for "Risk Source" input in EA, one of the following parameter must be in message MT4/5 settings for getting sell order risk information from Tradingview alert message
    1. risk_lots=
    2. risk_cncy_amt=
    3. risk_pct_bal_loss=
    4. risk_pct_bal_mgn=
    5. risk=


sell examples
  • 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
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=sell_001, symbol=EURUSD, risk_lots=0.1 (note: create a EURUSD short position whose trid is sell_001)


slippage=

Set the maximum allowed slippage pips of the trade. This parameter is only used for market order


slippage= examples
  • 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


comment= examples
  • 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.

The EA will show "EA is halted by eaoff message" on the chart.
Tradingview alert message to stop MetaTrader 4/5 EA

eaoff examples
  • token=master19dd529542d4b79d2bc4,signal=eaoff


eaon

Reactivates the TradingRouter EA from halt.

eaon examples
  • token=master19dd529542d4b79d2bc4,signal=eaon


symboloff

Disable one symbol.

symboloff examples
  • token=master19dd529542d4b79d2bc4,signal=symboloff, symbol=EURUSD

    note: this command will disable the symbol EURUSD, any following commands regarding EURUSD will be ignored.


symbolon

Reactive one symbol. After a symbol is disabled by symboloff, you can use symbolon to reactivate the symbol

symbolon examples
  • token=master19dd529542d4b79d2bc4,signal=symbolon, symbol=EURUSD

    note: this command will reactive the symbol EURUSD, any following commands regarding EURUSD will work.


clrallsymbol

Reactive all symbols. This command will reactivate all symbols which have been disabled by symboloff.

clrallsymbol examples
  • token=master19dd529542d4b79d2bc4,signal=clrallsymbol


close all

Close all positions and delete all pending orders, regardless of symbol

If you use the advanced trid= parameter feature, only positions/orders whose trid is the same as the trid in this message will be closed/deleted

Plesae note, if you don't use trid in closeall, then all positions/orders will be closed/deleted, regardless of whether a position has a trid or has no trid.

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.



Safety Measure

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



closeall examples
  • 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.)


closeall with trid examples 1
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t_001, symbol=GBPUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t_001, symbol=AUDUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t_002, symbol=GBPUSD, risk_lots=0.2
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t_002, symbol=CADUSD, risk_lots=0.2
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=GBPUSD, risk_lots=0.3
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.3
  • token=master19dd529542d4b79d2bc4,signal=closeall,symbol=EURUSD, trid=t_001 (note: if TradingRouter is running on EURUSD chart, then the first and second positions will be closed because their trid is t_001, which is the same as the trid in this closeall message. All other positions will keep open )


closeall with trid examples 2
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t_001, symbol=GBPUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t_001, symbol=AUDUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t_002, symbol=GBPUSD, risk_lots=0.2
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t_002, symbol=CADUSD, risk_lots=0.2
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=GBPUSD, risk_lots=0.3
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.3
  • token=master19dd529542d4b79d2bc4,signal=closeall,symbol=EURUSD (note: if TradingRouter is running on EURUSD chart, all the 6 positions will be closed because there is no trid in the closeall message)


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.

closealleaoff treats trid= the same way as closeall. If you use the advanced trid= parameter feature, only positions/orders whose trid is the same as the trid in this message will be closed/deleted

Plesae note, if you don't use trid in closealleaoff, then all positions/orders will be closed/deleted, regardless of whether a position has a trid or has no trid.

The EA will show "EA is halted by closealleaoff message" on the chart.
another Tradingview alert message to stop MetaTrader 4/5 EA


Safety Measure

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



closealleaoff examples
  • 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 you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed

Plesae note, if you don't use trid in closelong, then all long positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.



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.



closelong examples
  • token=master19dd529542d4b79d2bc4,signal=closelong,symbol=EURUSD


closelong with trid example 1
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, trid = t001,risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, trid = t002, risk_pct_bal_loss=3, sl_pips=100
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_cncy_amt=200, sl_pct=3
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t001, symbol=EURUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4,signal=closelong, trid = t001, symbol=EURUSD
  • Note:

    In this example, closlong will close long positions whose symbol=EURUSD and trid=t001. The first and fourth positions have trid=t001, so the frist and fourth positions will be closed and other positions keep open



closelong with trid example 2
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, trid = t001,risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, trid = t002, risk_pct_bal_loss=3, sl_pips=100
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_cncy_amt=200, sl_pct=3
  • token=master19dd529542d4b79d2bc4, signal=buy, trid=t001, symbol=EURUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4,signal=closelong, symbol=EURUSD
  • Note:

    In this example, closlong does not have trid, so all the 4 positions will be closed regardless of whether they have trid or have no trid.



closeshort

Close all short positions of the specified symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed

Plesae note, if you don't use trid in closeshort, then all short positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.



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.



closeshort examples
  • token=master19dd529542d4b79d2bc4,signal=closeshort, symbol=EURUSD


closeshort with trid example 1
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, trid = t001,risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, trid = t002, risk_pct_bal_loss=3, sl_pips=100
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_cncy_amt=200, sl_pct=3
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t001, symbol=EURUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4,signal=closeshort, trid = t001, symbol=EURUSD
  • Note:

    In this example, closeshort will close short positions whose symbol=EURUSD and trid=t001. The first and fourth positions have trid=t001, so the frist and fourth positions will be closed and other positions keep open



closeshort with trid example 2
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, trid = t001,risk_lots=0.1
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, trid = t002, risk_pct_bal_loss=3, sl_pips=100
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_cncy_amt=200, sl_pct=3
  • token=master19dd529542d4b79d2bc4, signal=sell, trid=t001, symbol=EURUSD, risk_lots=0.1
  • token=master19dd529542d4b79d2bc4,signal=closeshort, symbol=EURUSD
  • Note:

    In this example, closeshort does not have trid, so all the 4 positions will be closed regardless of whether they have trid or have no trid.



closelongbuy

Close all long positions of the specified symbol and open a new long position of the specified symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

If you use the advanced new_trid= parameter, the created long position will have a trid which is the same as new_trid

Plesae note, if you don't use trid in closelongbuy, then all long positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.

trid and new_trid can be the same



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.



closelongbuy examples
  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, risk_lots=0.5


closelongbuy trid example
  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, trid=t003, risk_lots=0.5

    close all long EURUSD positions whose trid is t003. The new created EURUSD long position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, trid=t003, new_trid=t006, risk_lots=0.5

    close all long EURUSD positions whose trid is t003. The new created EURUSD long position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, new_trid=t006, risk_lots=0.5

    close all long EURUSD positions regardless of trid. The new created EURUSD long position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, risk_lots=0.5

    close all long EURUSD positions regardless of trid. The new created EURUSD long position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closelongbuy, symbol=EURUSD, trid=t003, risk_lots=0.5, new_trid=t003

    close all long EURUSD positions whose trid is t003. The new created EURUSD long position's trid is also t003



closelongsell

Close all long positions of the specified symbol and open a new short position of the specified symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

If you use the advanced new_trid= parameter, the created short position will have a trid which is the same as new_trid

Plesae note, if you don't use trid in closelongsell, then all short positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.

trid and new_trid can be the same



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.



closelongsell examples
  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, risk_lots=0.5


closelongsell trid example
  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, trid=t003, risk_lots=0.5

    close all long EURUSD positions whose trid is t003. The new created EURUSD short position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, trid=t003, new_trid=t006, risk_lots=0.5

    close all long EURUSD positions whose trid is t003. The new created EURUSD short position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, new_trid=t006, risk_lots=0.5

    close all long EURUSD positions regardless of trid. The new created EURUSD short position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, risk_lots=0.5

    close all long EURUSD positions regardless of trid. The new created EURUSD short position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closelongsell, symbol=EURUSD, trid=t003, new_trid=t003, risk_lots=0.5

    close all long EURUSD positions whose trid is t003. The new created EURUSD short position's trid is also t003



closeshortbuy

Close all short positions of the specified symbol and open a new long position of the specified symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

If you use the advanced new_trid= parameter, the created long position will have a trid which is the same as new_trid

Plesae note, if you don't use trid in closelongsell, then all short positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.

trid and new_trid can be the same



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.



closeshortbuy examples
  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, risk_lots=0.5


closeshortbuy trid example
  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, trid=t003, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD long position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, trid=t003, new_trid=t006, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD long position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, new_trid=t006, risk_lots=0.5

    close all short EURUSD positions regardless of trid. The new created EURUSD long position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, risk_lots=0.5

    close all short EURUSD positions regardless of trid. The new created EURUSD long position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closeshortbuy, symbol=EURUSD, trid=t003, new_trid=t003, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD long position's trid is also t003



closeshortsell

Close all short positions of the specified symbol and open a new short position of the specified symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

If you use the advanced new_trid= parameter, the created short position will have a trid which is the same as new_trid

Plesae note, if you don't use trid in closelongsell, then all short positions of the symbol will be closed, regardless of whether a position has a trid or has no trid.

trid and new_trid can be the same



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.



closeshortsell examples
  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, risk_lots=0.5


closeshortsell trid example
  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, trid=t003, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD short position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, trid=t003, new_trid=t006, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD short position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, new_trid=t006, risk_lots=0.5

    close all short EURUSD positions regardless of trid. The new created EURUSD short position's trid is t006

  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, risk_lots=0.5

    close all short EURUSD positions regardless of trid. The new created EURUSD short position does not have trid

  • token=master19dd529542d4b79d2bc4,signal=closeshortsell, symbol=EURUSD, trid=t003, new_trid=t003, risk_lots=0.5

    close all short EURUSD positions whose trid is t003. The new created EURUSD short position's trid is also t003



newsltplong

Modify the stop loss and take profit of the long positions

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be modified.

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.



newsltplong examples
  • 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)


newsltplong trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltplong, trid=t003 symbol=EURUSD, sl_pips = 100 (note: all EURUSD long positions whose trid is t003 will have stop loss changed to 100 pips below current price)
  • token=master19dd529542d4b79d2bc4,signal=newsltplong, trid=t004 sl_pips = 100 (note: all long positions whose trid is t004 will have stop loss changed to 100 pips below current price)




newsltpshort

Modify the stop loss and take profit of the short positions

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be modified.

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.



newsltpshort examples
  • 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)


newsltpshort trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltpshort, trid=t003 symbol=EURUSD, sl_pips = 100 (note: all EURUSD short positions whose trid is t003 will have stop loss changed to 100 pips below current price)
  • token=master19dd529542d4b79d2bc4,signal=newsltpshort, trid=t004 sl_pips = 100 (note: all short positions whose trid is t004 will have stop loss changed to 100 pips below current price)


closelongpct

Close a percentage of long positions (based on your initial volume) of the specific symbol,

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

The percentage is set at Partial Close Percentage of your TradingRouter EA



how much percentage of trades will be closed by a Tradingview alert message

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



closelongpct examples set Partial Close Percentage to 30, whenever closelongpct comes, 30% of initial volume will be closed.
30% of trades will be closed by a Tradingview alert message
  • 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 )


closelongpct trid example
  • token=master19dd529542d4b79d2bc4,signal=closelongpct, trid=t002, symbol=EURUSD (note: Assume Partial Close Percentge is 30, all long EURUSD positions whose trid is t002 will be closed 30%. )


closeshortpct

Close a percentage of short positions (based on your initial volume) of the specific symbol,

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

The percentage is set at Partial Close Percentage of your TradingRouter EA



how much percentage of trades will be closed by a Tradingview alert message

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



closeshortpct examples set Partial Close Percentage to 30, whenever closeshortpct comes, 30% of initial volume will be closed.
30% of trades will be closed by a Tradingview alert message
  • 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 )


closeshortpct trid example
  • token=master19dd529542d4b79d2bc4,signal=closeshortpct, trid=t002, symbol=EURUSD (note:Assume Partial Close Percentage is 30, all short EURUSD positions whose trid is t002 will be closed 30%)




closelongvol

Close long positions up to the indicated volume for the specific symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

symbol= and risk= are required parameters.



closelongvol examples
  • token=master19dd529542d4b79d2bc4,signal=closelongvol, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD long position)

closelongvol trid example
  • token=master19dd529542d4b79d2bc4,signal=closelongvol, trid=t001, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD long positions whose trid is t001)


closeshortvol

Close short positions up to the indicated volume for the specific symbol.

If you use the advanced trid= parameter feature, only positions whose trid is the same as the trid in this message will be closed.

symbol= and risk= are required parameters.



closeshortvol examples
  • token=master19dd529542d4b79d2bc4,signal=closeshortvol, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD short position)

closeshortvol trid example
  • token=master19dd529542d4b79d2bc4,signal=closeshortvol, trid=t001, symbol=EURUSD, risk=0.1 (note: close 0.1 lot of EURUSD short positions whose trid is t001)


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.

If you use the advanced trid= parameter feature, the created buylimit order will have a trid. You can later identify this order by the trid. When the order becomes position, the position has the same trid



buylimit examples
  • 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

buylimit trid example
  • token=master19dd529542d4b79d2bc4, signal=buylimit, symbol=EURUSD, trid=buyeur001, price_exact=1.023, risk_lots=0.1

    0.1 lot of buylimit EURUSD order is created, the entry price is 1.023, the trid is buyeur001. When the entry price is hit and the order becomes a long EURUSD position, the position's trid is also buyeur001.


selllimit

Place a sell limit order above the current market price.

If you use the advanced trid= parameter feature, the created sell limit order will have a trid. You can later identify this order by the trid. When the order becomes position, the position has the same trid



selllimit examples
  • 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

selllimit trid example
  • token=master19dd529542d4b79d2bc4, signal=selllimit, symbol=EURUSD, trid=sell001, price_exact=1.231, risk_lots=0.1

    0.1 lot of EURUSD sell limit order is created, the entry price is 1.231 and the trid of this order is sell001. When the entry price is hit and the order becomes 0.1 lot short position of EURUSD, this position's trid is also sell001.


buystop

Place a buy stop order above the current market price.

If you use the advanced trid= parameter feature, the created buy stop order will have a trid. You can later identify this order by the trid. When the order becomes position, the position has the same trid



buystop examples
  • 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

buystop trid example
  • token=master19dd529542d4b79d2bc4, signal=buystop, symbol=EURUSD, trid=buy0010, price_exact=1.231, risk_lots=0.1

    0.1 lot of buy stop order for EURUSD is created, its trid is buy0010. When the entry price is hit and this order becomes 0.1 lot of long position, this position's trid is also trid.


sellstop

Place a sell stop order below the current market price.

If you use the advanced trid= parameter feature, the created sell stop order will have a trid. You can later identify this order by the trid. When the order becomes position, the position has the same trid



sellstop examples
  • 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

sellstop trid example
  • token=master19dd529542d4b79d2bc4, signal=sellstop, symbol=EURUSD, trid=sell001, price_exact=1.0123, risk_lots=0.1

    0.1 lot sell stop order for EURUSD is created, its trid is sell001. When the entry price is hit, the order becomes 0.1 lot short position for EURUSD, the position's trid is also sell001.


Price Parameter (for Pending Order)

Price parameter is used to determine the entry price of pending order. It has the following 4 parameters

    1. price_pips=
    2. price_pct=
    3. price_exact=
    4. 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

price_pips= examples
  • 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

price_pct= examples
  • 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.

price_exact= examples
  • 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


different pending order entry price types on the Trading Router MT4/5 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.


price= example 1
choose pending order entry price type as pips on the Trading Router MT4/5 EA
  • 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 )

price= example 2
choose pending order entry price type as percentage on the Trading Router MT4/5 EA
  • 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 )

price= example 3
choose pending order entry price type as exact price on the Trading Router MT4/5 EA
  • 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 you use the advanced trid= parameter feature, only the buylimit and buystop pending orders whose trid is the same as the trid in the message will be deleted.



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.



cancellong examples
  • token=master19dd529542d4b79d2bc4,signal=cancellong,symbol=EURUSD

cancellong trid example
  • token=master19dd529542d4b79d2bc4,signal=cancellong,symbol=EURUSD, trid=001

    the buylimit and buystop EURUSD pending orders whose trid is 001 will be deleted.


cancelshort

delete all selllimit and sellstop pending orders of the specified symbol.

If you use the advanced trid= parameter feature, only the selllimit and sellstop pending orders whose trid is the same as the trid in the message will be deleted.



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.



cancelshort examples
  • token=master19dd529542d4b79d2bc4,signal=cancelshort,symbol=EURUSD

cancelshort trid example
  • token=master19dd529542d4b79d2bc4,signal=cancelshort,symbol=EURUSD, trid = 001

    The selllimit and sellstop EURUSD pending orders whose trid is 001 will be deleted.


cancellongbuylimit

delete all buylimit and buystop pending orders of the specified symbol and place a buy limit order below the current market price.

If you use the advanced trid= parameter feature, only the specified symbol's buylimit/buystop pending orders whose trid is the same as the trid in this message will be deleted.

If you use the advanced new_trid= parameter, the created buy limit order will have a trid which is the same as new_trid

Plesae note, if you don't use trid in cancellongbuylimit, then all buylimit and buystop pending orders of the specified symbol will be deleted, regardless of whether an order has a trid or has no trid.

trid and new_trid can be the same


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.


cancellongbuylimit examples
  • token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100

cancellongbuylimit trid example
  • token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001, new_trid = 111

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buylimit EURUSD pending order is created, this pending order's trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, new_trid = 111

    all buylimit and buystop EURUSD pending orders are deleted. A 0.3 lot of buylimit EURUSD pending order is created, this pending order's trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buylimit EURUSD pending order is created, this new created buylimit order does not have trid.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuylimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001, new_trid = 001

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buylimit EURUSD pending order is created, this pending order's trid is also 001.


cancellongbuystop

delete all buylimit and buystop pending orders of the specified symbol and place a buy stop order above the current market price.

If you use the advanced trid= parameter feature, only the specified symbol's buylimit/buystop pending orders whose trid is the same as the trid in this message will be deleted.

If you use the advanced new_trid= parameter, the created buy stop order will have a trid which is the same as new_trid

Plesae note, if you don't use trid in cancellongbuystop, then all buylimit and buystop pending orders of the specified symbol will be deleted, regardless of whether an order has a trid or has no trid.

trid and new_trid can be the same


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.


cancellongbuystop examples
  • token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100

cancellongbuystop trid example
  • token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001, new_trid = 111

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buystop EURUSD pending order is created, this pending order's trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, new_trid = 111

    all buylimit and buystop EURUSD pending orders are deleted. A 0.3 lot of buystop EURUSD pending order is created, this pending order's trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buystop EURUSD pending order is created, this new created buystop order does not have trid.


  • token=master19dd529542d4b79d2bc4,signal=cancellongbuystop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=001, new_trid = 001

    all buylimit and buystop EURUSD pending orders whose trid is 001 are deleted. A 0.3 lot of buystop EURUSD pending order is created, this pending order's trid is also 001.


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.

If you use the advanced trid= parameter feature, only the specified symbol's selllimit/sellstop pending orders whose trid is the same as the trid in this message will be deleted.

If you use the advanced new_trid= parameter, the new created sell limit order will have a trid which is the same as new_trid

Plesae note, if you don't use trid in cancelshortselllimit, then all selllimit and sellstop pending orders of the specified symbol will be deleted, regardless of whether an order has a trid or has no trid.

trid and new_trid can be the same


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.


cancelshortselllimit examples
  • token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100

cancelshortselllimit trid example
  • token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000, new_trid=111

    all EURUSD selllimit and sellstop pending orders whose trid is 000 are deleted. A 0.3 lot of EURUSD selllimit pending order is created, its trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, new_trid=111

    all EURUSD selllimit and sellstop pending orders are deleted. A 0.3 lot of EURUSD selllimit pending order is created, its trid is 111.


  • token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000

    all EURUSD selllimit and sellstop pending orders whose trid is 000 are deleted. A 0.3 lot of EURUSD selllimit pending order is created, the new created selllimit order does not have trid.


  • token=master19dd529542d4b79d2bc4,signal=cancelshortselllimit,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000, new_trid=000

    all EURUSD selllimit and sellstop pending orders whose trid is 000 are deleted. A 0.3 lot of EURUSD selllimit pending order is created, its trid is also 000.


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.

If you use the advanced trid= parameter feature, only the specified symbol's selllimit/sellstop pending orders whose trid is the same as the trid in this message will be deleted.

If you use the advanced new_trid= parameter, the new created sell stop order will have a trid which is the same as new_trid

Plesae note, if you don't use trid in cancelshortsellstop, then all selllimit and sellstop pending orders of the specified symbol will be deleted, regardless of whether an order has a trid or has no trid.

trid and new_trid can be the same


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.


cancelshortsellstop examples
  • token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, sl_pips=100

cancelshortsellstop trid examples
  • token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000, new_trid = 001

    all EURUSD sell limit and sell stop pending orders whose trid is 000 will be deleted. A 0.3 lot of EURUSD sell stop pending order will be created, this pending order's trid is 001


  • token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000

    all EURUSD sell limit and sell stop pending orders whose trid is 000 will be deleted. A 0.3 lot of EURUSD sell stop pending order will be created, this pending order does not have trid


  • token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, new_trid = 001

    all EURUSD sell limit and sell stop pending orders will be deleted. A 0.3 lot of EURUSD sell stop pending order will be created, this pending order's trid is 001


  • token=master19dd529542d4b79d2bc4,signal=cancelshortsellstop,symbol=EURUSD,price_pct=1, risk_lots=0.3, trid=000, new_trid = 000

    all EURUSD sell limit and sell stop pending orders whose trid is 000 will be deleted. A 0.3 lot of EURUSD sell stop pending order will be created, this pending order's trid is also 000


newsltpbuylimit

Modify the stop loss and take profit of buy limit pending order

If you use the advanced trid= parameter feature, only the buy limit pending orders whose trid is the same as the trid in this message will be modified.

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.



newsltpbuylimit examples
  • 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)

newsltpbuylimit trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, symbol=EURUSD, sl_pips = 100, trid=t000 (note: all EURUSD buy limit orders whose trid is t000 will have stop loss set 100 pips below entry price)
  • token=master19dd529542d4b79d2bc4,signal=newsltpbuylimit, sl_pips = 200, trid=t000 (note: all buy limit orders whose trid is t000 will have stop loss set 200 pips below entry price)


newsltpbuystop

Modify the stop loss and take profit of buy stop pending order

If you use the advanced trid= parameter feature, only the buy stop pending orders whose trid is the same as the trid in this message will be modified.

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.



newsltpbuystop examples
  • 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)

newsltpbuystop trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, symbol=EURUSD, sl_pips = 100, trid=t000 (note: all EURUSD buy stop orders whose trid is t000 will have stop loss set 100 pips below entry price)
  • token=master19dd529542d4b79d2bc4,signal=newsltpbuystop, sl_pips = 200, trid=t000 (note: all buy stop orders whose trid is t000 will have stop loss set 200 pips below entry price)


newsltpselllimit

Modify the stop loss and take profit of sell limit pending order

If you use the advanced trid= parameter feature, only the sell limit pending orders whose trid is the same as the trid in this message will be modified.

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.



newsltpselllimit examples
  • 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)

newsltpselllimit trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, symbol=EURUSD, sl_pips = 100, trid=t000 (note: all EURUSD sell limit orders whose trid is t000 will have stop loss set 100 pips above entry price)
  • token=master19dd529542d4b79d2bc4,signal=newsltpselllimit, sl_pips = 200, trid=t001 (note: all sell limit orders whose trid is t001 will have stop loss set 200 pips above entry price)


newsltpsellstop

Modify the stop loss and take profit of sell stop pending order

If you use the advanced trid= parameter feature, only the sell stop pending orders whose trid is the same as the trid in this message will be modified.

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.



newsltpsellstop examples
  • 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)

newsltpsellstop trid example
  • token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, symbol=EURUSD, sl_pips = 100, trid=t000 (note: all EURUSD sell stop orders whose trid is t000 will have stop loss set 100 pips above entry price)
  • token=master19dd529542d4b79d2bc4,signal=newsltpsellstop, sl_pips = 200, trid=t000 (note: all sell stop orders whose trid is t000 will have stop loss set 200 pips above entry price)


comment=

Add a string into the order's comment section.


comment could be any string, you can include space in the comment, but cannot have "," and "=". You can putenv "," after comment, but not in comment


comment= examples
  • 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

  1. sl_pips=
  2. sl_pct=
  3. sl_price=
  4. 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

Tradingview alert message will set the stop loss of trades

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.

sl_pips= examples
  • 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.

sl_pct= examples
  • 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.

sl_price= examples
  • 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.

different stop loss types

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


sl= example 1

stop loss type is pips and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl=100 (note: stop loss is 100 pips above open price)
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, sl=120 (note: stop loss is 120 pips below open price)


sl= example 2

stop loss type is percentage and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl=3 (note: stop loss is 3% away from open price )


sl= example 3

stop loss type is exact price and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, sl=1.0234 (note: stop loss is 1.0234 )


Take Profit Parameter

Take profit has the following 4 parameters

  1. tp_pips=
  2. tp_pct=
  3. tp_price=
  4. 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

MT4/5 take profit comes from Tradingview alert messages

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.

tp_pips= examples
  • 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.

tp_pct= examples
  • 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.

tp_price= examples
  • 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.

different take profit types

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


tp= example 1

take profit type is pips and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp=100 (note: take profit is 100 pips below open price)
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk_lots=0.2, tp=120 (note: take profit is 120 pips above open price)


tp= example 2

take profit type is percentage and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp=3 (note: take profit is 3% away from open price )


tp= example 3

take profit type is exact price and the value comes from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk_lots=0.1, tp=1.2234 (note: take profit is 1.2234 )


Risk Parameter

Risk parameter is used to determine the volume of the order. Risk has the following 5 parameters

  1. risk_lots=
  2. risk_cncy_amt=
  3. risk_pct_bal_loss=
  4. risk_pct_bal_mgn=
  5. 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

risk management information comes from Tradingview alert messages

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

risk_lots= examples
  • 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

You must set stop loss for the order if you use risk_cncy_amt=, because the volume of the order is calculated according to stop loss. You can use either Stop Loss Parameter in message or stop loss settings in EA to set stop loss.


risk_cncy_amt= examples
  • 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.

You must set stop loss for the order if you use risk_pct_bal_loss=, because the volume of the order is calculated according to stop loss. You can use either Stop Loss Parameter in message or stop loss settings in EA to set stop loss. The value of risk_pct_bal_loss cannot exceed 100.


risk_pct_bal_loss= examples
  • 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



risk_pct_bal_mgn= examples
  • 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


different risk types for Trading Router MT4/5 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=.



risk= example 1

Trading Router MT4/5 EA's risk type is lots and the values come from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk=0.1 (note: a sell order for 0.1 lot of EURUSD is created)
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=AUDUSD, risk=0.2 (note: a buy order for 0.2 lot of AUDUSD is created)


risk= example 2

Trading Router MT4/5 EA's risk type is currency amount and the values come from Tradingview alert messages

  • 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.)


risk= example 3

Trading Router MT4/5 EA's risk type is balance percentage and the values come from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk=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.)


risk= example 4

Trading Router MT4/5 EA's risk type is margin percentage and the values come from Tradingview alert messages

  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=EURUSD, risk=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. )


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

  1. If there is no lifetime= parameter in the message, the pending order will not expire.(good until cancel)
  2. If lifetime=GTC, the pending order will not expire.(good until cancel)
  3. If lifetime=DAY, the pending order will expire at the end of day
  4. If lifetime=SPEC, the expiration time of the pending order is specified by the expiration= parameter
  5. 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


MT5 expiration parameter examples
  • 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)

MT4 expiration parameter examples
  • 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= or betriggerpct= is satisfied

There are two parameters: trigger parameter (betrigger= or betriggerpct=) and offset parameter (beoffset= or beoffsetpct=) . The two parameters are required in a command if you want Breakeven feature.

beoffset should be less than betrigger

You can use Breakeven parameter for both market order and pending order



1. betrigger parameter

Breakeven will be activated after the position gains this number of pips or gains percentage.

The two options are betrigger= and betriggerpct=

betriggerpct= is available since Trading Router EA version 2.07

If you use betrigger=, Breakeven will be activated after the position gains the number of pips specified in betrigger=

If you use betriggerpct=, Breakeven will be activated after the position gains the number of percentage specified in betriggerpct=

If you use both betrigger= and betriggerpct= in the same command, betriggerpct= will be ignored and only betrigger= will be used to trigger Breakeven

betrigger= should be a positive integer and betriggerpct= should be a positive decimal



2. beoffset parameter

This parameter sets the offset from the entry price when Breakeven is triggerred

The two options are beoffset= and beoffsetpct=

beoffsetpct= is available since Trading Router EA version 2.07

beoffset= specifies pips from entry price while beoffsetpct= specifies percentage 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). If beoffsetpct=1, when breakeven is activated, stop loss will be placed at 1 percent above entry price for long position(or 1 percent below entry price for short position).

If you use both beoffset= and beoffsetpct= in the same command, only beoffset= will be used and beoffsetpct= will be ignored.

beoffset= should be 0 or a positive integer and beoffsetpct= should be 0 or a positive decimal



Breakeven parameter examples
  • 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)
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=AUDUSD, risk_lots=0.1, sl_pips=100, betriggerpct=0.1, beoffsetpct=0.8 (note: create a short position for 0.1 lot of EURUSD, when the position gains 0.1% , stop loss is placed at 0.8% below open price)
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=AUDUSD, risk_lots=0.1, sl_pips=100, betrigger=10, beoffsetpct=0.8 (note: create a short position for 0.1 lot of EURUSD, when the position gains 10 pips , stop loss is placed at 0.8% below open price)
  • token=master19dd529542d4b79d2bc4, signal=sell, symbol=AUDUSD, risk_lots=0.1, sl_pips=100, betriggerpct=0.1, beoffset=8 (note: create a short position for 0.1 lot of EURUSD, when the position gains 0.1% , stop loss is placed at 8 pips below open price)


SL Trailing Parameter

Automatically move SL with the direction in favour of the position (move up for long position, and move down for short position)

There are three parameters: trigger parameter (trailtrig= or trailtrigpct=), distance parameter (traildist= or traildistpct=) and step parameter (trailstep= or trailsteppct=). All the three parameters are required in a command if you want SL Trailing feature.

You can use SL Trailing Parameter for both market order and pending order



1. trigger parameter

Stop loss trailing will be activated after a position gains a number of pips or percentage

The two options are trailtrig= and trailtrigpct=

trailtrigpct= is available since Trading Router EA version 2.07

If you use trailtrig=, the SL Trailing feature will be triggerred when a position gains the number of pips specified by trailtrig=

If you use trailtrigpct=, the SL Trailing feature will be triggerred when a position gains the number of percentage specified by trailtrigpct=

If you use both trailtrig= and trailtrigpct= in the same command, trailtrig= will be used and trailtrigpct= will be ignored

trailtrig= should be a positive integer and trailtrigpct= should be a positive decimal



2. distance parameter

The distance of trailing stop loss from current price

The two options are traildist= and traildistpct=

traildistpct= is available since Trading Router EA version 2.07

If you use traildist=, the stop loss is set x pips away from current price while x is specified by traildist=

If you use traildistpct=, the stop loss is set x percentage away from current price while x is specified by traildistpct=

If you use both traildist= and traildistpct=, traildist= will be used and traildistpct= will be ignored

traildist= should be a positive integer and traildistpct= should be a positive decimal



3. step parameter

Move trailing stop loss once price moves in favour by a number of pips or percentage

The two options are trailstep= and trailsteppct=

trailsteppct= is available since Trading Router EA version 2.07

If you use trailstep=, the stop loss will move once the price moves in favour by a number of pips specified by trailstep=

If you use trailsteppct=, the stop loss will move once the price moves in favour by a number of percentage specified by trailsteppct=

If you use both trailstep= and trailsteppct= in the same command, trailstep= will be used and trailsteppct= will be ignored

trailstep= should be a positive integer and trailsteppct= should be a positive decimal



SL Trailing parameter examples
  • 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. )
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, trailtrigpct=1.2, traildistpct=0.1, trailsteppct=0.1 (note: create a long position for 0.1 lot of EURUSD. When position gains 1.2%, stop loss is placed at 0.1% below current price. Then whenever price moves up 0.1%, stop loss is placed at 0.1% below current price. )
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, trailtrigpct=1.2, traildist=20, trailsteppct=1 (note: create a long position for 0.1 lot of EURUSD. When position gains 1.2%, stop loss is placed at 20 pips below current price. Then whenever price moves up 1%, stop loss is placed at 20 pips below current price. )
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1, trailtrig=100, traildistpct=2, trailsteppct=1.1 (note: create a long position for 0.1 lot of EURUSD. When position gains 100 pips, stop loss is placed at 2% below current price. Then whenever price moves up 1.1%, stop loss is placed at 2% below 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

  1. accfilter_bal=
  2. accfilter_eqt=
  3. accfilter_mgn=
  4. accfilter_mgn_pct=
  5. 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"

MT4/5 terminal log to show the account balance
accfilter_bal= examples
  • 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"

MT4/5 terminal log to show the account equity
accfilter_eqt= examples
  • 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"

MT4/5 terminal log to show the account margin
accfilter_mgn= examples
  • 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"

MT4/5 terminal log to show the account margin percentage
accfilter_mgn_pct= examples
  • 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

different filter types

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"

check MT4/5 terminal log to see if trades are filtered by account balance
accfilter= example 1
filter trades by account balance
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account balance is greater then 5234.5 )


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"

check MT4/5 terminal log to see if trades are filtered by account equity
accfilter= example 2
filter trades by account equity
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account euqity is greater then 5234.5 )


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"

check MT4/5 terminal log to see if trades are filtered by account free margin
accfilter= example 3
filter trades by account free margin
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account free margin is greater then 5234.5 )


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"

check MT4/5 terminal log to see if trades are filtered by account margin percentage
accfilter= example 4
filter trades by account margin percentage
  • token=master19dd529542d4b79d2bc4, signal=buy, symbol=EURUSD, risk_lots=0.1 , accfilter=5234.5 (note: create a long position for 0.1 lot of EURUSD if your current account margin level is greater then 5234.5 )


Advanced Feature



1. Multi Commands

You can send multiple commands in one alert message from Tradingview to MT5 MT4. Besides the main command, you can send extra 5 commands in one message.

Extra commands and main command share the same token, so you only need one token field.

Extra command has the same syntax as main command except that extra command's parameter has suffix _x1 or _x2 or _x3 or _x4 or_x5

The main commands will be executed first, followed by _x1 command (if there is _x1 command), followed by _x2 command (if there is _x2 command), followed by _x3 command (if there is _x3 command), followed by _x4 command (if there is _x4 command), followed by _x5 command (if there is _x5 command),

Extra command can be any commands except eaon and eaoff. You can only use the main command to send eaon or eaoff

multi commands example 1
  • token = master19dd529542d4b79d2bc4, signal = buy, symbol = EURUSD, risk_lots = 0.01, signal_x1=sell, symbol_x1=GBPUSD, risk_lots_x1=0.02

    (note: first create a long position for 0.01 lot of EURUSD , then create a short position for 0.02 lot of GBPUSD)
  • token = master19dd529542d4b79d2bc4, signal=closeall, symbol=USDCHF, signal_x1 = buy, symbol_x1 = EURUSD, risk_lots_x1 = 0.01, sl_pips_x1=1000, signal_x2=selllimit, symbol_x2=GBPUSD, risk_lots_x2=0.02, price_pips_x2=200, signal_x3=newsltplong, symbol_x3=EURUSD, sl_pips_x3=200, signal_x4=cancelshort, symbol_x4=GBPUSD, signal_x5=closelong, symbol_x5=EURUSD

    note: first close all positions and pending orders (main command), then create a long position of EURUSD for 0.01 lot, the sl is 1000 pips(_x1 command), then create a sell limit pending order of GBPUSD for 0.02 lot(_x2 command), then change the sl of the long EURUSD to 200 pips(_x3 command), then cancel the GPBUSD pending order(_x4 command), then close the long EURUSD position(_x5 command)


multi commands example 2: more parameters
  • token = master19dd529542d4b79d2bc4, signal = buy, symbol = EURUSD, risk_lots=0.03, betrigger=10, beoffset=0 , signal_x1 = buystop, symbol_x1 = EURUSD, price_pips_x1=100, risk_lots_x1=0.1, trailtrig_x1=5, traildist_x1=30 trailstep_x1=3

    note: first create a long position of EURUSD for 0.03 lots with breakeven parameter, then create a buystop pending order of EURUSD for 0.1 lots with sl trailing parameter.


2. Multi SL/TP

You can have multiple stop loss and multiple take profit for a position or pending order.

The maximum number of stop loss and take profit is 5, which means you can have 5 stop loss and 5 take profit for a position or pending order

You can only use pips to set the multiple sl/tp

Please note, the multiple sl/tp will not be show on the S/L column or T/P column on MT4/5, the Trading Router EA will maintain these multiple sl/tp and will partial close positions when these sl/tp is hit

The syntax of multi sl msl=p..v..p..v..p..v, p means stop loss pips, v means volume to be closed when this pips is hit.

There could be maximum 5 p..v, p could be any value, but every p's value must be greater than the previous p's value

You can use space to seperate each p..v, but could not use any other charater like ',', ';'. So "p10 v0.02", "p 10 v 0.02", "p 10 v 0.01 p 20 v 0.02" are correct p..v, but "p10 , v0.02" and "p10 v0.02 , p20 v0.01" are wrong. Also you could not use space within value, "p 10 v 0.0 1" is wrong because there is space in the value "0.0 1"

For example msl=p20 v0.01 p30 v0.02 p45 v0.01 p50 v0.1 p60 v0.1 means when stop loss hits 20 pips, we close 0.01 lot, when stop loss hits 30 pips, we close 0.02 lot, when stop loss hits 45 pips, we close 0.01 lot, when stop loss hits 50 pips we close 0.1 lot, when stop loss hits 60 pips, we close 0.1 lot.

multi sl/tp example 1
  • token = master19dd529542d4b79d2bc4, signal = buy ,symbol = GBPUSD, risk_lots=0.1, msl= p10v0.01 p25v0.02 p35v0.01 p50v0.01 p60v0.01, mtp=p10 v 0.01 p20v0.02 p30 v 0.01 p40 v 0.01 p50 v0.01

    note: create a long position of GBPUSD for 0.1 lot with 5 stop losses and 5 take profits,
    when position loses 10 pips, close 0.01 lot (p10v0.01)
    when position loses 25 pips, close 0.02 lots (p25v0.02)
    when position loses 35 pips, close 0.01 lot (p35v0.01)
    when position loses 50 pips, close 0.01 lot (p50v0.01)
    when position loses 60 pips, close 0.01 lot (p60v0.01)


    when position gain 10 pips, close 0.01 lot (p10 v 0.01)
    when position gain 20 pips, close 0.02 lots (p20v0.02)
    when position gain 30 pips, close 0.01 lot (p30 v 0.01)
    when position gain 40 pips, close 0.01 lot (p40 v 0.01 )
    when position gain 50 pips, close 0.01 lot (p50 v0.01)


multi sl/tp example 2: invalid value
  • token = master19dd529542d4b79d2bc4, signal = buy ,symbol = GBPUSD, risk_lots=0.1, msl= p10v0.01 p25v0.02 p20v0.01 p50v0.01 p60v0.01

    note: in this command the firts sl is 10 pips, the second sl is 25 pips, the third sl is 20 pips which is less than the second sl, hence the third sl is invalid, the fourth and the fifth sl will not be used as they are after invalid st, only the first and the second sl will be used.

    So this command will create a long position of GBPUSD for 0.1 lot with 2 stop losses,
    when position loses 10 pips, close 0.01 lot (p10v0.01)
    when position loses 25 pips, close 0.02 lots (p25v0.02)


multi sl/tp example 3 : multi commands with multi sl/tp

You can use multi sl/tp in multi commands

  • token = master19dd529542d4b79d2bc4, signal = buy ,symbol = GBPUSD, risk_lots=0.1, msl= p10v0.01 p25v0.02 p35v0.01 p50v0.01 p60v0.01, signal_x1=buy, symbol_x1 = USDJPY, risk_lots_x1=0.2, msl_x1 = p20v0.01 p30 v0.02

    note: first create a long position of GBPUSD for 0.1 lots with 5 stop losses:
    when position loses 10 pips, close 0.01 lot (p10v0.01)
    when position loses 25 pips, close 0.02 lots (p25v0.02)
    when position loses 35 pips, close 0.01 lot (p35v0.01)
    when position loses 50 pips, close 0.01 lot (p50v0.01)
    when position loses 60 pips, close 0.01 lot (p60v0.01)

    then create a long position of USDJPY for 0.2 lots with 2 stop losses:
    when position loses 20 pips, close 0.01 lot (p20v0.01)
    when position loses 30 pips, close 0.02 lot (p30 v0.02 )


3. Delay Execution

You can delay the execution of a marking order for upto 3600 seconds. The syntax is delay=. You can put any value between 1 to 3600, if the value is more than 3600, this command will be ignored and no order will be executed.

This parameter only works for market buy and market sell.

delay execution example 1:
  • token = master19dd529542d4b79d2bc4, signal = buy, symbol=AUDUSD, risk_lots=0.01, delay=30

    note: when Trading Router EA receives this message, it will wait for 30 seconds, then create a long position of AUDUSD for 0.01 lot


delay execution example 2: invalid value
  • token = master19dd529542d4b79d2bc4, signal = buy, symbol=AUDUSD, risk_lots=0.01, delay=3601

    note: This message will be ignored because the delay value is more than 3600, no position will be created.


4. Identify Order

You can identify every single order by using trid= parameter and new_trid= parameter.


4.1 trid=

When you send buy, sell, buylimit, selllimit, buystop and sellstop messages, you can specify trid. Then the created orders/positions will have this trid. You can use this trid to identify orders/positions in other messages.

trid= parameter can be put at any place after signal parameter in the message

trid can be the combination of letters, digits and "_". No other charaters can be used. For example "buy_001", "buy_002", "sell_00001" are all legitimate trid.

trid is case sensetive, for example "buy001" and "Buy001" are different trid

Multiple orders/positions can share the same trid



trid example 1
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=my_aud_buy_1, symbol=AUDUSD, risk_lots=0.01
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=my_aud_buy_2, symbol=AUDUSD, risk_lots=0.02
  • token = master19dd529542d4b79d2bc4, signal = closelong, trid=my_aud_buy_2, symbol=AUDUSD

Note:

The first message creates a AUDUSD long position of 0.01 lot, the trid for this position is my_aud_buy_1.

The second message creates a AUDUSD long position of 0.02 lot, the trid for this position is my_aud_buy_2.

The third message closes a AUDUSD long position whose trid is my_aud_buy_2.

So after the third message is sent, the position created by the second message is closed because this position's trid is my_aud_buy_2, but the position created by the first message keeps open because this position's trid is not my_aud_buy_2.



trid example 2
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=my_aud_buy_1, symbol=AUDUSD, risk_lots=0.01
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=my_aud_buy_2, symbol=AUDUSD, risk_lots=0.02
  • token = master19dd529542d4b79d2bc4, signal = closelong, symbol=AUDUSD

Note:

The first message creates a AUDUSD long position of 0.01 lot, the trid for this position is my_aud_buy_1.

The second message creates a AUDUSD long position of 0.02 lot, the trid for this position is my_aud_buy_2.

The third message closes all AUDUSD long positions

So after the third message is sent, the positions created by both the first and the second messages are closed because the closelong message does not specify any trid



trid example 3
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=aud_buy_market, symbol=AUDUSD, risk_lots=0.01
  • token = master19dd529542d4b79d2bc4, signal = buylimit, trid=aud_buy_limit, symbol=AUDUSD, price_pips = 20, risk_lots=0.02
  • Afer a while when the buylimit entry price is hit and a position is created by buylimit, this position's trid is aud_buy_limit.
  • token = master19dd529542d4b79d2bc4, signal = closelong, trid=aud_buy_limit, symbol=AUDUSD

Note:

The first message creates a AUDUSD long position of 0.01 lot, the trid for this position is aud_buy_market.

The second message creates a AUDUSD pending order of 0.02 lot, the entry price is 20 pips away from current price, the trid for this pending order is aud_buy_limit.

After a while, the entry price of the buylimit pending order is hit and the buylimit pending order becomes a position, this position's trid is aud_buy_limit.Now you have two AUDUSD long positions, one is 0.01 lot and another one is 0.02 lot.

The third message closes a AUDUSD long position whose trid is aud_buy_limit.

So after the third message is sent, the position created by the second message is closed because this position's trid is aud_buy_limit, but the position created by the first message keeps open because this position's trid is not aud_buy_limit.



trid example 4, share trid
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=aud_buy_1, symbol=AUDUSD, risk_lots=0.01
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=aud_buy_1, symbol=AUDUSD, risk_lots=0.02
  • token = master19dd529542d4b79d2bc4, signal = buy, trid=aud_buy_2, symbol=AUDUSD, risk_lots=0.03
  • token = master19dd529542d4b79d2bc4, signal = buy, symbol=AUDUSD, risk_lots=0.04
  • token = master19dd529542d4b79d2bc4, signal = closelong, trid=aud_buy_1, symbol=AUDUSD

Note:

In this example, the first and second positions have the same trid=aud_buy_1, the third position has trid=aud_buy_2, the fourth has no trid.

The closelong mesage has trid=aud_buy_1, so it only closes the first and the second positions. The third and fourth positions will keep open after closelong is sent.


4.2 new_trid=

new_trid= is used in closelongbuy, closelongsell, closeshortbuy, closeshortsell, cancellongbuylimit, cancellongbuystop, cancelshortselllimit and cancelshortsellstop for setting trid of the new created position

new_trid is case sensetive, for example "buy001" and "Buy001" are different new_trid



new_trid example 1
  • token = master19dd529542d4b79d2bc4, signal = closelongbuy, trid=aud_001, symbol=AUDUSD, risk_lots=0.01, new_trid=aud_002

Note:

close all AUDUSD long positions whose trid is aud_001, and create a new long AUDUSD position whose trid is aud_002


4.3 trid and Multi Commands

trid= and new_trid= can be used in Multi Commands like other parameters. You can use trid_x1=, trid_x2=, trid_x3=, trid_x4, trid_x5=, new_trid_x1=, new_trid_x2=, new_trid_x3=, new_trid_x4, new_trid_x5=


trid=, new_trid= Multi Command example 1
  • token = master19dd529542d4b79d2bc4, signal=buy,symbol=AUDUSD, trid=t001, risk_lots = 0.01, signal_x1=sell, symbol_x1=EURUSD, trid_x1=t002, risk_lots_x1 = 0.02, signal_x2= closelongbuy, trid_x2=t003, symbol_x2=CADUSD, risk_lots_x2=0.01, new_trid_x2=t004

Note:

This message has 3 commands. The first command create a long AUDUSD posistion of 0.01 lot, the trid is t001. The second command create a short EURUSD position of 0.02 lot, the trid is t002. The third command close all long CADUSD positions whose trid is t003 and create a new long CADUSD position whose trid is t004.



5. Trading Time Section

Available since Trading Router EA version 2.07

You can specify two time sections for buy, sell, buylimit, selllimit, buystop, sellstop commands. When the current broker server time is within the time sections, the commands can be executed, otherwise the commands will be ignored.

The parameters are sec_a_start=, sec_a_end=, sec_b_start=, sec_b_end=

sec_a_start= and sec_a_end= define the start time and end time of the section A. sec_b_start= and sec_b_end= define the start time and end time of the section B. You can have both section A and section B in a command. Or you can only have either section A or section B in a command.

The value of the parameters are HH:MM:SS like 13:39:58 which means 13:39:58 pm of the broker server time

The minimum time is 00:00:00 and the maximum time is 24:00:00


Trading Time Section Example
  • token = master19dd529542d4b79d2bc4, signal=buy,symbol=AUDUSD, risk_lots = 0.01, sec_a_start=09:30:00, sec_a_end=16:30:00

Note:

If the current broker server time is between 09:30:00 am and 16:30:00 pm, this command will buy AUDUSD of 0.01 lot, otherwise this command will not have any effect. For example if the broker server time is now 10:00:00 and this command comes, then a long AUDUSD position of 0.01 will be created, if the broker server time is now 08:00:00 am and this command comes, then this command will be ignored because 08:00:00 am is outside of the section A

  • token = master19dd529542d4b79d2bc4, signal=buy,symbol=AUDUSD, risk_lots = 0.01, sec_a_start=09:30:00, sec_a_end=16:30:00, sec_b_start=19:00:00, sec_b_end=21:30:00

Note:

This command specifies both section A and section B. If the current broker server time is between 09:30:00 am and 16:30:00 pm or between 19:00:00 pm and 21:30:00 pm, this command will buy AUDUSD of 0.01 lot, otherwise this command will not have any effect. For example if the broker server time is now 10:00:00 and this command comes, then a long AUDUSD position of 0.01 will be created, because 10:00:00 is within section A. If the broker server time is now 20:00:00 and this command comes, then a long AUDUSD position of 0.01 will be created, because 20:00:00 is within section B. If the broker server time is now 22:00:00 am and this command comes, then this command will be ignored because 22:00:00 am is neither in section A nor in section B.

  • token = master19dd529542d4b79d2bc4, signal=buy,symbol=AUDUSD, risk_lots = 0.01, sec_a_start=18:00:00, sec_a_end=24:00:00, sec_b_start=00:00:00, sec_b_end=06:00:00

Note:

This command specifies both section A and section B. The section A ends at 24:00:00 and section B starts at 00:00:00, so the section A and section B are connected, the available section is from 18:00:00 pm to 06:00:00 am of the next day. If this command comes after 06:00:00 am and before 18:00:00 pm, the command will be ignored, otherwise the command will be executed.



6. pending_duration=

Available since Trading Router EA version 2.07

This parameter is used in pending order command, buylimit, selllimit, buystop and sellstop. It specifies how long a pending order can sit there before execution. If a pending order sits longer than specified time and has not been executed, the pending order will be cancelled. The unit of this parameter's value is second. The maximum value of this paramter 36000, which means 36000 seconds(10 hours)

Risk: If a pending order's pending duration is after the market close time, then this pending order will not be cancelled. For example if you set pending_duration= to 2 minutes, but the market closes in one minute, the pending order will not be cancelled after 2 minutes. To avoid this risk, you can use Trading Time Section to specify the trading time so that the pending order will not be created if your pending duration is after market close time. Please refer to the following Pending Duration With Trading Time Section Example


Pending Duration Example
  • token = master19dd529542d4b79d2bc4, signal = buylimit, symbol=AUDUSD, price_pips = 20, risk_lots=0.02, pending_duration=60

Note:

This command will place a buylimit pending order. This pending order will be cancelled after 60 seconds if it has not been executed.


Pending Duration With Trading Time Section Example
  • token = master19dd529542d4b79d2bc4, signal = buylimit, symbol=AUDUSD, price_pips = 20, risk_lots=0.02, pending_duration=60,

Note:

Assume the market closes at 16:30:00. In the above command, the pending_duration= is 60 seconds, if the above command comes at 16:29:30, a pending buylimit order will be created and it is expected to be cancelled at 16:30:30. But as market is close at 16:30:00, the pending buylimit order will not be cancelled at 16:30:30, and the pending buylimit order will keep sitting there when the market opens next day.

  • token = master19dd529542d4b79d2bc4, signal = buylimit, symbol=AUDUSD, price_pips = 20, risk_lots=0.02, pending_duration=60, sec_a_start=00:00:00, sec_a_end=16:28:00

Note:

Assume the market closes at 16:30:00. In the above command, the pending_duration is 60 seconds, the trading time section is from 00:00:00 to 16:28:00. If the above command comes before 16:28:00, a buylimit pending order will be created and it will be cancelled after 60 seconds if not being executed. If the above command comes after 16:28:00, no buylimit pending order will be created, so there is no risk that a pending order cannot be cancelled after market close time.