MetaTrader 4 and 5 platforms users can count on publishing agents to automate data updates from the demo and real accounts. In addition to data synchronization, agents are responsible for interfacing with EAs that implement the library available on the website to allow their supervision.
TP Agent for MT5
Publishing agents are expert advisors that you need to attach on a chart of any symbol, preferably one with a frequent tick generation. You shall configure them to monitor the strategies individually, which means that it's necessary to inform the strategy IDs used on the website. That way, the EA can identify the trades in the account and update the database.
TP Agent running
Optionally, you can synchronize all account's historical data with the server. With this, besides the information segregated by strategy, you will find consolidated account information in your profile, presented in a specific report. Basic account data, such as broker name, account number, balances, pending orders, and open positions, are always synchronized, regardless of the option to update all account data.
You can download the agents directly from your profile page, and there you can also find the API key, which is required to enable the tools. Below you find a description of publishing agents' configuration parameters.
Publishing agents rely on internal MetaTrader functions to send data to the servers, so no DLL is required. You will only need to allow WebRequest to the following URL in your terminal options at the Expert Advisors tab:
Allowed WebRequest URLs
These are the parameters available:
TP Agent inputs
Your tradingportfolios .com API key: Here, you must insert your API key. Just copy the key presented in your profile and paste into this field. It will act as a login to identify your user on the site and authorize data sending to your account.
Type of Strategy IDs input, entered below: When indicating the strategy IDs to be supervised, you must inform how you will do this. Whenever the EA starts, it will build a list of strategies and synchronize the history with the server. The following options are available:
List of IDs: This is the simplest method of informing which strategies the publishing agent should monitor. Just enter the IDs as registered on the website, which should be the same as the trading account's magic numbers. To separate multiple IDs use the comma ',' character. You can specify a valid range of IDs by separating two IDs with a dash '-' for your convenience. For example, the list 100, 102, 105, 111-115, would configure eight strategies for monitoring, with IDs 100, 102, 105, 111, 112, 113, 114, and 115.
Warning: You should use ranges only if you want to monitor all strategies within the range. Otherwise, the agent might generate a list with several invalid strategies. It may cause even more trouble if the option to create strategies automatically is active.
All magics in history except listed below: With this option, the agent will search the entire history available for the account and collect the magic numbers used. You can optionally define a list of numbers that the agent should not consider for monitoring.
All magics in history including listed below: Like the previous option, the agent will search the entire history available for the account and collect the magic numbers used. In this case, you can include a list with other IDs that don't exist in the history yet (for example, when you have configured a new strategy to run in the account).
Online profile with the following name: From your profile page on the website, in the same card where the tools are listed, you can manage profiles to define which strategies the agent should monitor in an account. For each profile created, you must specify a unique name, and this name must be informed in the agent's setting to make the IDs list. The configuration of profiles allows the flexibility of magic numbers used in the account. It's possible to map a site ID to a different magic number in the account with them. Further on, you will find more information about these profiles.
CSV file with the following name: Using this option, you can pass the IDs list using a CSV format file. This file must be located in the folder MQL5\Files (or MQL4\Files) on your terminal, and you must enter the full file name in the following parameter (for example, tp-strategies.csv). Like online profiles, with CSV files, it's possible to map site IDs to different magic numbers in the trading account. Thus, you must fill the CSV file with two columns, according to the following example:
Site ID, Account Magic 7654, 5003 3210, 9003 8002, 8002 2009, 2009
In the first column (Site ID), you should insert the unique identifier number defined for the strategy online. In the second column (Account Magic), you must fill in the magic number used in the account. If the magic number is equal to the ID, repeat the same number. In the example above, strategies 7654 and 3210 would be mapped to magics 5003 and 9003, respectively, while strategies 8002 and 2009 would remain with the same numbers defined on the website.
Tip: Whenever possible, try to keep the same number for the site ID and magic. It will make identification easier and allows you to use the automatic history search option. For specific cases where this is not possible, you can perform these mappings using online profiles or CSV files.
>> List of IDs, profile or file name: This parameter must be filled in (or left blank) depending on the option selected, as described above. You can insert lists with IDs (configured or ignored), name of a profile defined on the website, or name of a file on the computer.
Create strategies on profile, if missing: When synchronizing with the server, agents verify if the strategy already exists. By default, they don't monitor strategies that you have not created previously. With this option, you can force the creation of strategies on the website when they don't exist. The app will create a strategy with standard data that you can change later on the website. Be careful when using this option in conjunction with the definition of ranges in the list of IDs. Confirm that all IDs are valid to avoid creating strategies on the site accidentally.
MetaTrader server’s timezone: Select here the timezone of your broker's MetaTrader server. The app uses this information to adjust the time of the strategies within a portfolio. If you're not sure which time to fill in, keep the default 'UTC.'
Update all account data to your profile: This parameter controls whether the agent should send the complete account history to the server or not. You may prefer not to send all account data and store only the history discriminated by strategy. In this case, keep this parameter as false.
Try to update data after every trade: Defines whether the agent might send updates immediately when a change in the account is noticed, such as a new order or filling of a pending order. This option makes data updates more dynamic, and you can quickly view the new account status online. If it is false, the agent will synch data only at the time interval defined in the next parameter.
Cyclic update interval (minutes): This is the time interval (in minutes) for data synchronization with the server. This synchronization occurs periodically regardless of any changes in the account.
Execute full update at startup (slow): Publishing agents keep track of what they have already sent to the server to avoid data traffic already synchronized and consequent processing overhead. However, in some situations, you may find that some deals are missing in the site history or wish to do an integrity check of all data. You can force a complete update at the agent startup for these situations, which will send all account data again. In this case, the server will check the data for consistency and store new deals, if necessary.
Enable expert advisor control from site: If your expert advisors implement the Trading Portfolios website's interface library, you must enable this option. It will allow the agent to exchange information with other EAs and update enabling or blocking status with the website.
Initial date to search history: This parameter is only available for the MT5 agent. Indicates the start date to search for trades in the account history. You may always keep this parameter at the default value. Still, if you want to restrict the search to a more recent period, when you had already synchronized the previous data with the server, this parameter can make the search more efficient.
You can create profiles and associate them with publishing agents. Each instance of a publishing agent may point to a unique profile on the website. You can use multiple instances of publishing agent EAs with different profiles each.
New agent profile
If you define new profile, you can select the monitored strategies directly on the Trading Portfolios website. The publishing agent configured with this profile will automatically monitor these strategies.
To manage publishing agent profiles, access your profile page, and in the Software tools card, click on the agent's "Profiles" link for the platform of interest. The next screen will show a table with the profiles already configured, and you will see a link to add a new profile at the top of the table.
When you click on the link to create a new profile, you will need to fill in a name and select which strategies are part of this profile. You will immediately be redirected to a page with the profile details, where you can see a table with all the configured strategies.
On the details page, there is also a section called "Custom mappings." In this section, it's possible to define strategy mappings for different magic numbers in the trading account. This feature is similar to that obtained with the CSV files. To create a new mapping, click on the "+ New" link, and in the next dialog, select the strategy and define the magic number used in the account.
If you configure the agent with this profile and custom mapping, you can confirm in the Experts messages if the mapping was adopted by the agent.