HOW TO CONTROL OUR TRADE COPIERS PROGRAMMATICALLY

 


How to control our trade copiers programmatically



1. Stop and resume trade copiers


At our MT4/MT5 related trade copiers, each copier ea has one set of variables that you could set MT4/MT5 global variables to stop or resume that ea.


ea variables:

Enable Hold-Up Feature? - default is false.  set that as true if you want to enable this control feature

Global Variable Name - you could assign your preferred global variable name.


At your own ea or indicator, write that global variable as 1 to stop that copier ea or 0 to resume per your logic.  Our copier ea will seamlessly monitor that global variable value to stop or resume itself.



2. Fetch copy trading platform's account balance and position info


There are two approaches that you could use:


Method A


This for MT4/MT5 related trade copiers and you want to fetch that data by your own ea or indicator.


At that copier ea


set 'Write Log' variable as true

set 'Output position info?' variable as true

keep 'Output position info in seconds' variable as default.


That MT4/MT5 copier ea will fetch the target trading platforms (e.g. cTrader, TradeLocker) latest account balance and position info via its counterpart bridge app and output to below folder:

your MT4/MT5 data folder/MQL5 (or MQL4)/Files/TradingConnectivity/Logs/

That 'Files' folder is your MT4/MT5 sanbox path that your ea or indicator can directly read without using external dll.

The log file name format is: [mt4/mt5]to[target platform]_[date].log

e.g.

mt5totradelocker_20260817.log

It will auto append new log messages to that day's log file.  That is why please do not set output interval less than 15 seconds otherwise one day log file will becomes too large.


- The position log message example:

 [2026.08.16 12:36:22] Account 1533685 position update: {"account":"1533685","balance":9740.78,"positions":[{"id":"216172782116546753","symbol":"BTCUSD","volume":0.01,"side":"buy","stopLoss":0,"takeProfit":0},{"id":"216172782116546754","symbol":"BTCUSD","volume":0.01,"side":"buy","stopLoss":0,"takeProfit":0}]}


You could write your json parser to parse json data inside {}.


- If balance value is not available, it will show "balance":null


- Please note that MatchTrader position json data format is different and doesn't include balance data.


- Please be aware 'balance' is not 'equity'.  'Equity' value keeps changing if you have positions opened - while 'balance' only change when one position gets closed.


- Applicable trade copiers of this Method A

'MT4/MT5 to cTrader' non api

'MT4/MT5 to DxTrade' non api

'MT4/MT5 to MatchTrader'

'MT4/MT5 to The5ers'

'MT4/MT5 to ThinkMarkets'

'MT4/MT5 to TradeLocker' non api

'MT4/MT5 to Tradovate'



Method B - 


If you want to fetch that data by your own app other than by ea or indicator


At that bridge app,


add below two lines at config.ini file


outputPosition=on

outputInterval=3


default output interval is every 3 seconds.

save that config.in file.  restart that bridge app.

Once all accounts are logged in, that bridge app will generate a snapshot text file called 'positions.txt' inside 'output' subfolder.


That snapshot file will keep self refreshed as long as that bridge app is live and accounts stay connected.


The output content example:


updated:2026-08-16T18:53:15Z,1786906395


{"accounts":[{"account":"1071576","balance":5004.38,"positions":[]},{"account":"9121099","balance":103676.39,"positions":[{"id":"661852265","symbol":"BTCUSD","volume":0.01,"side":"buy","stopLoss":60033.45,"takeProfit":68033.45},{"id":"661862884","symbol":"BTCUSD","volume":0.02,"side":"buy","stopLoss":60114.9,"takeProfit":69114.9},{"id":"661862888","symbol":"BTCUSD","volume":0.01,"side":"sell","stopLoss":0,"takeProfit":0}]}]}


First line is the output timestamp of your computer time in UTC

The json part includes the whole list of accounts and its balance and position info.



- Applicable bridge apps:

cTrader

DxTrade

The5ers

ThinkTrader

TradeLocker 

Tradovate









Popular posts from this blog

TRADE COPIER USER GUIDE LIST

FREE EVALUATION WITH LIMITED SYMBOLS

TRADE COPIER DEMO VIDEO LIST