METATRADER TO DXTRADE TRADE COPIER - API APPROACH
This is the user guide for 'MT4/MT5 to DxTrade' Trade Copier EA
API Approach
Please be aware of three limitations before using this copier:
(a) If you need 'TP/SL modification' feature, the initial TP/SL has to be placed along with the market order. 'TP/SL copy' is required to enabled at this copier EA variable.
(b) This copier EA uses DxTrade API to design. Some DxTrade brokers have banned API calls. Please check this with your broker before rent/purchase.
(c) DxTrade has imposed the network flow limit and throttling schemes. This copier strictly follows their rule to design, but still reserve one variable switch to send out data concurrently.
Rate Limits & Throttling
The DXtrade REST API supports per-client configurable maximum API access rate. This rate limits how frequently the API can be accessed. There are four types of rate limits:
- For login requests based on IP of the request. Default value 1 per second
- For 'get data' requests based on client session, default value 2 per second.
- For trading requests(placing / modifying / canceling orders) based on client session, default value 1 per second.
- For requests for a large amount of data to return (e.g., all portfolios of all accounts) Default value permits accessing each resource available to client no faster than once a second.
If access rate is exceeded, the server responds with the 429 Too Many Requests
.
The impacts to copier performance are:
- Each trade has to be placed one second apart. That will make multiple account's concurrent trades to be sequentially placed with one second interval.
- Login action is also one request per second. If you attach this copier to two charts, it will login at the same time when MT4 restarts that might get unexpected result.
If any failed order entry or exit, please check API response messages at MT4/MT5 log window. API response message is something like {"orderId":381975072}
To force copier reconnect to broker server, just switch copier's chart timeframe to another.
Below is the installation steps:
1. Install MT4 or MT5 copier EA.
Put “MT4ToDxTrade.ex4” or “MT5ToDxTrade.ex5” to \MQL4\Experts\ or \MQL5\Experts\ folder.
At MT4 or MT5, “Menu” → “Tools” → “Options”, at below selection, click “Allow DLL Import” - as this EA needs network authentication for use.
1. Please attach this signal EA to ONLY one chart.
This EA can fetch multiple symbol/trade event signals of this MT4/MT5. If you want to have another copier for different DxTrade account, you can elect to attach to another chart.
If you want to temporarily stop this EA, please click 'Stop Signals' button on the trade panel. MT4/MT5 'auto trading' or 'algo trading' button is not applicable as this EA won't make any trade.
2. Below required info are what you've registered or got from your DxTrade Brokers. Those info are required to log in DxTrade server api. Please check the welcome email from your broker.
(a) user name
(b) password
(c) broker server - e.g.
https://demo.dx.trade
or
https://dxtrade.alphacapitalgroup.uk
or
https://trade.brightfunded.com
'Account Ids' field can be left as blank. Account name or number is shown on the right upper corner after you login webtrader at browser. If this variable is blank, this copier bot will request to get all available account numbers from your DxTrade broker and then select the first one to send the copy trade signals.
If you want to specify which DxTrade account to get copy signals, the input format is:
single account as
cfd_23vg91
multiple accounts as
cfd_ytyaT2,cfd_plTh96
(separated by comma)
- please ONLY put the accounts with same account type (e.g. CFD or Crypto or Stock) at one copier EA
- If multiple accounts are input, EA will send out the copy signal to each of them (i.e. multiple account support). Special note: please DO NOT put more than 3 accounts on this list. If you need more accounts to be copied, open another chart to attach copier with different set of account list.
This copier will cross check what account number you've input with what it gets from DxTrade broker. If it's not consistent, EA will hold up.
4. Symbol mapping list - if DxTrade instrument name is different with MetaTrader's, please input as below format (MT4/MT5's symbol name first, comma, then DxTrade's, then semi-colon)
BTCUSD,BITCOIN;
if two pairs,
BICUSD,BITCOIN;XAUUSD,GOLD;
- 'MetaTrader Symbol Prefix To Be Ignored' and 'MetaTrader Symbol Postfix To Be Ignored'
assume you input prefix en and that MT4/MT5 symbol is enEURUSD, this copier EA will remove the prefix 'en' and convert it as EURUSD before sending to DxTrade.
assume you input postfix .st and that MT4/MT5 symbol is EURUSD.st, this copier EA will remove the postfix '.st' and convert it as EURUSD before sending to DxTrade.
- Add Extra Symbol Postfix To DxTrade
All symbol names will add this common postfix to DxTrade. For instance, if setting .PRO, EURUSD will be converted as EURUSD.PRO and GBPUSD as GBPUSD.PRO so you don't need to set one by one at 'Symbol Mapping List' variable.
> Please note that - this EA will automatically convert one symbol format of xxx/xxx at DxTrade accounts. For instance, to convert EURUSD to EUR/USD will be handled by EA itself. You don't need to do this at above manual input of 'symbol mapping list'
5. Lot multiplier list - if you want to multiply the lot value to DxTrade, for instance, input
EURUSD,10;XAUUSD,2;
If simply input
10
All trade lots at MT4/MT5 will be multiplied by 10.
6. Partial close feature is enabled by default - while TP/SL price copy is *disabled* by default.
'Copy Limit/Stop Orders' is also *disabled' by default.
'No Close Signals If That Dealt Order Has TP/SL Prices' ---> if 'TP/SL price copy' function is enabled, it's recommended to enable this. This feature is to refrain sending MT4/MT5 position *exit* signal to DxTrade as DxTrade trades already have got its own TP/SL.
Due to market price deviation between two trading platforms, if you want to get consistent copy result, please DO NOT enable 'copy TP/SL' or 'copy Limit/Stop' features.
7. Lot mode - default is 'follow MT4/MT5 order lot'; another two options are 'Equity-To-Equity' and 'Fixed Lot'
8. Order magic number list - you could assign specific magic number for trade signaling.
For multiple magic, separate each with comma.
For instance, 3413434,1343292
Default is a blank string, i.e. applying on all trades.
Special reminder:
If you put your ea's magic number and want to limit the copy to it, e.g. magic number 3421243
Then MT4/MT5 signal ea will only scan orders with magic number = 3421243
Kindy be aware MT4/MT5 manual order's magic number is 0.
If you want to have that signal ea cover BOTH manual orders and your own ea orders, it should be set like
0,3421243
i.e. include 0 at magic number list
9. Applicable symbol list - you could restrict to specific symbol/instruments. Separate each with comma, e.g. EURUSD,XAUUSD,USOIL
Default is a blank string, i.e. applying on all symbols.
10. Applicable comment list - you could restrict to specific order comment. Separate each with comma.
> Reverse trade - if setting true, it will reverse the trade signal to DxTrade.
For instance, a LONG trade will be signaled as a SHORT trade.
11. 'API Network Throttling?' --> default is enabled, i.e. follow DxTrade API throttling restriction. You could disable it as an option.
12. As there are great variations of customer custom needs of control or filter requirements, this copier use the alternative approach to accommodate.
If enable "Enable Hold-Up Feature?" variable (default is false), MT4/MT5 signal EA will keep checking whether MT4/MT5 global variable named
DXCOPYDISABLE
is 1 or not. If that equals 1, MT4/MT5 signal EA will hold up. It doesn't equal or that global variable is not set, MT4/MT5 signal EA will keep running.
You could self write (or hire a developer) to write an EA or indicator to set value to that global variable with your own control/filter logics.
13. As network API-based copier is inherently less reliable than local copier (due to client/broker network stability), this copier will output the API response messages to mt4/mt5 log. Once you get any trade issue in the future, you could check the log file and see how broker api server responds.
==============
Special note for SwayFunded customers:
1. Sway Charts is a variant of DxTrade trading platform by using direct DxTrade api calls. As such it can use DxTrade api approach copier to copy trades with some tweaks on input variables.
2. At copier variable, follow below variable mapping to input
- 'User Name' - input 'Platform User' name assigned at Sway dashboard
- 'Password' - input 'Password' assigned at Sway dashboard
- 'Server' - input
https://api.swaycharts.io/
do not input
https://webtrader.swaycharts.io/
- 'Account List' -
leave it as blank string first
once this copier get login sucess, open MT4/MT5 experts log window
and you will see the full account list of this user name account
that actual 'account id' is slightly different with what 'account id' shown at Sway dashboard.
if this 'account list' variable is left as blank string, this copier will use the first 'actual' account id listed at this log output to make copy trades.
if your Sway account have more than one account ids, you could specify which account you want to use and set to this copier variable.
===================
==============
Special Notes for DxTrade/TradeLocker 'Network Throttling' restriction
As many customers are concerning the impact of DxTrade/TradeLocker 'network throttling' restirction towards their strategy or multiple account copy, I elaborate again how this restriction works and how this copier accommodates this restriction:
- What is 'Network Throttling'?
You could google this term. It's intentionally imposed by server provider to limit the client network concurrent multiple requests. If it's implemented by trading API providers, that means that brokers won't like your concurrent multiple trading requests to make their trading server too overloaded.
- What are implemented by DxTrade & TradeLocker?
DxTrade has explicitly stated their network throttling rules at their API doc:
https://demo.dx.trade/developers/#/DXtrade-REST-API
(see 'rate limits & throttling' section)
TradeLocker doesn't mention that at their API doc but from recent experiments it shows similar behavior (but a bit relaxed than DxTrade). For concurrent multiple trading requests, TradeLocker API will reject some by responding 'too frequent requests'.
DxTrade network throttling rules have applied on login, date fetch, trading request, etc. If we look at the trading request rule:
For trading requests(placing / modifying / canceling orders) based on client session, default value 1 per second.
That means if you send the concurrent 3 consecutive trade entry or exit or modification requests to DxTrade API, it will only take the first trading request but reject the rest by responding 'too many requests' - as those concurrent multiple trading requests are made WITHIN one second.
Please note multiple account copy also leads to concurrent multiple trading requests scenario - as copier has to send another account trading activities concurrently.
- How this copier accommodates DxTrade/TradeLooker 'Network Throttling' restriction?
All API response messages will be output at MT4/MT5 log window (no matter success or failure). If you get any missed order entry or exit at DxTrade/TradeLooker side, please check MT4/MT5 log first for API failure response.
As we are unable to change DxTrade/TradeLooker restriction behavior, this copier provides below variables so you could set or adjust (at the bottom of copier variable window):
(a) 'API Network Throttling?' - default is 'true', i.e. enabled. This copier will follow their API throttling rule.
(b) 'Throttling Delay in Second' - Default value is 1, i.e. one second. If above variable is set 'false', this variable is not applicable.
You could first try to set 'API Network Throttling?' as 'false' (i.e. disabled). This copier will instantly send out all concurrent trading entry/exit/modification to API server.
You can do this as experiement. Just quickly repeatedly click MT4/MT5 one-click panel to generate concurrent multiple order entries (or make concurrent multiple order exits). Then check MT4/MT5 log window how API reponse messages say. If you're confident that DxTrade/TradeLooker don't restrictly execute their throttling rule or your strategy won't have concurrent trade entry/exit scenario, you could set this variable 'false' as disabled.
As this 'API Network Throttling?' is set 'true' as default, for a concurrent trade entrie (e.g. three entries), this copier will do the following actions sequentially
- send the first trade entry request to API, and queue the rest of two
- wait 1-2 second (depending on the throttling delay time you've set + a little time margin)
- send the second trade entry request
- wait 1-2 second
- send the third trade entry request
Please note the whole process cannot exceed 30 seconds
Suggestions:
(a) Review your strategy behavior if timing delay really matters.
(b) Talk to your brokers if they are unable to remove network throttling rule especially for your account (but I am not so sure they are willing to do this exceptionally)