MetaTrader client terminal is perfect for automating trading strategies. It has all tools necessary for trading robot developers ‒ powerful C++ based MQL4/MQL5 programming language, convenient MetaEditor development environment and multi-threaded strategy tester that supports distributed computing in MQL5 Cloud Network. In this article, you will find out how to move your client terminal to the virtual environment with all custom elements.
How to Provide the Reliable Round-the-Clock Operation of the Terminal?
A trader may need a terminal running 24 hours a day in the following three cases:
- a trader has a trading robot developed by his or her efforts or ordered from programmers;
- a trader has an Expert Advisor purchased in the Market;
- a trader has subscribed to a Signal.
All these cases require constant connection to a trade server and uninterrupted power supply. Using a home PC is not always possible and convenient. Until recently, the most popular solution has been renting allocated computing capacities as VDS or VPS from specialized companies.
MetaTrader platform offers much more convenient and quick solution ‒ you can rent a virtual server for your trading account right from the client terminal.
What Is a Virtual Terminal
Virtual terminal has been developed specifically for working in Virtual Hosting Cloud network offering rental services. Any trader may rent a ready-made virtual server with already arranged trading environment in a few mouse clicks right from the client terminal.
Allocating a Virtual Server
To receive a virtual terminal, select the appropriate trading account and execute "Register a Virtual Server" command in the context menu.
Virtual Hosting Wizard window appears. It shows how the virtual hosting network works. The process of obtaining a virtual server consists of three steps. First, you will find out how to prepare for migration. After that, you will select the nearest virtual server with minimal network latency to your broker's trade server.
You can choose 1440 free minutes provided to each registered MQL5.com user or select one of the offered service plans. Finally, you will select the data migration mode depending on your objectives:
- complete migration is necessary if you want to simultaneously launch Expert Advisors/indicators and trade copying;
- only Expert Advisors and indicators if subscription to signals is not required;
- only trade copying - only Signal copying settings (no charts or programs) are moved.
There are no limitations on the number of charts and Expert Advisors/indicators. The number of activations for products purchased in the Market is not decreased when launching them on a virtual terminal.
After selecting the migration mode, you can launch the virtual server immediately by clicking "Migrate now" or do that later at any time.
Congratulations! Now, you have your own virtual server with MetaTrader terminal ready for work!
Preparing for Migration
Before launching the virtual terminal, you should prepare an active environment for it - charts, launched indicators and Expert Advisors, Signal copying parameters and the terminal settings.
Charts and Market Watch
In the Market Watch, set up the list of symbols critical for your Expert Advisors' operation. We recommend that you remove all unnecessary symbols to decrease the tick traffic received by the terminal. There is no point in keeping hundreds of symbols in the "Market Watch" if only a couple of them are used for trading.
Open only the charts that you really need. Although there are no limitations on the number of open charts, there is no point in opening unnecessary ones. Color settings do not matter.
Set "Max bars in chart" parameter in Charts tab of the terminal settings. Some custom indicators are developed in a wasteful way and perform calculations on all history available on the chart. In that case, the lesser the specified value, the better. However, make sure that the indicator works correctly with these settings by restarting the terminal after changing this parameter.
The virtual terminal has been designed so that it automatically downloads all available history from a trade server, but not more than 500 000 bars are available on a chart.
Indicators and Expert Advisors
Apply to the charts all indicators and Expert Advisors that are necessary for the terminal's autonomous operation. Most trading robots do not refer to indicators on the charts, so check out and decide what you really need.
Products purchased on the Market and launched on the chart are also moved during migration. They remain completely functional, and the number of available activations is not decreased. Automatic licensing of purchased products without spending available activations is provided only for the virtual terminal.
DLL calls are completely forbidden in the virtual terminal. During the first attempt to call a function from DLL, the launched program is stopped with the critical error.
All external parameters of indicators and Expert Advisors should be set correctly. Check them once again before launching synchronization.
Scripts cannot be moved during migration even if they have been launched in an endless loop on the chart at the time of synchronization.
Virtual terminal can be automatically restarted when it is updated through the LiveUpdate, as well as during the maintenance of virtual hosting. Thus, all the programs intended to operate on the virtual platform must correctly process terminal stop and restart in order to correctly continue their operation after these events.
Terminal global variables are not migrated to the virtual hosting. If you need to initialize lots of variables when starting a program, you can use reading from files that can be passed using the "#property tester_file" directive.
If a certain file is required for an Expert Advisor or indicator, you can send it to the virtual terminal by specifying a #property parameter:
- #property tester_file "data_file_name"- for sending a file from <data_folder>\MQL5\Files or <data_folder>\MQL4\Files
- #property tester_indicator "indicator_name" - for sending a custom indicator from <data_folder>\MQL5\Indicators or <data_folder>\MQL4\Indicators
- #property tester_library - "library_name" - for sending a library from <data_folder>\MQL5\Libraries or <data_folder>\MQL4\Libraries
Please note that called libraries are identified and sent to the
hosting automatically during the migration even if they are not
specified. Therefore, you do not need to specify them. Also, you do not
need to specify indicators that are explicitly called in the code by
their names via the iCustom() function.
When migrating, these directives are identified by the terminal and the necessary files are sent. The file size should not exceed 64 MB.
Sample code for sending files of the following three types to the virtual terminal:
#property tester_file "trade_patterns.csv" // A data file an Expert Advisor is to work with. It should be specified if needed on the hosting #property tester_indicator "smoothed_ma.ex5" // Custom indicator file if the indicator name can be identified #property tester_library - "alglib.ex5" // Library of the functions called in an Expert Advisor. You do not need to specify it
Configuring Email, FTP and Signals
If an Expert Advisor is to send emails, upload data via FTP or copy Signal trades, make sure to specify all necessary settings. Set correct login and password of your MQL5.community account in Community tab. This is necessary for Signal copying.
It is highly recommended that you specify your MetaQuotes ID and allow sending messages of performed trades in Notifications tab. Thus, you will stay aware of what is going on at your trading account without even opening your terminal.
Permission to Trade and Signal Copying
The automated trading is always allowed in the virtual terminal. Therefore, any Expert Advisor with trading functions launched during synchronization can trade on the virtual terminal after the migration. Do not launch the Expert Advisors you are not sure about.
Regardless of whether autotrading is allowed or forbidden in your client terminal or in the properties of a launched Expert Advisor, any trading robot is allowed to trade after being moved to the virtual terminal.
Set necessary trade copying parameters in Signals tab. If a trading account has an active subscription and trade copying is allowed, permission to copy signals is disabled in the client terminal during migration. This is done in order to prevent the situation when two terminals connected to the same account copy the same trades simultaneously.
Trade copying is automatically enabled on the virtual terminal when migration is complete. Message about copy cancellation in the client terminal is also repeated in the journal.
Migration is transferring the current active environment from the client terminal to the virtual one. This is a simple and straightforward way to change the set of launched programs, open charts and subscription parameters in the virtual terminal.
Migration is performed during each synchronization of the client terminal. Synchronization is always a one-direction process - the client terminal's environment is moved to the virtual terminal but never vice versa. The virtual terminal status can be monitored via requesting the terminal's and Expert Advisors' logs as well as virtual server's monitoring data.
To perform synchronization, execute "Synchronize Environment" command and select migration type.
Thus, you always can change the number of charts and the list of symbols in the Data Window, the set of launched programs and their input parameters, the terminal settings and Signal subscription.
When performing migration, all data is recorded in the client terminal's log.
After the synchronization, open the virtual terminal's main journal to examine the actions performed on it.
In the newly opened log window, you can set a piece of text the journal entries are to be filtered by and a desired interval. After that, click Request to download the found logs.
Virtual terminal logs themselves are updated at each request and saved in <terminal data folder>/logs/hosting.<hosting_ID>.terminal and <terminal data folder>/logs/hosting.<hosting_ID>.experts.
Working with the Virtual Terminal
The rented virtual server status can also be easily monitored from the client terminal. Execute "Details" command in the context menu.
The newly opened dialog window shows the virtual server's monitoring data:
- CPU usage graph, %;
- memory usage graph, Mb;
- hard disk usage graph, Mb.
The main tab contains data on the virtual server itself and the terminal's active environment:
- server name and rent number;
- rent start date, MQL5.com account and trading account status;
- used service plan and remaining rental time;
- status - started or stopped.
Besides, the following data is displayed for the virtual terminal:
- last migration date and mode;
- data on Signal subscription's migration and disabling trade copying on the client terminal (if an active subscription is present);
- number of opened charts, Expert Advisors/indicators launched on it, moved EX4/EX5 libraries and created files.
The context menu of the rented server's icon is also used to launch and stop the virtual terminal. The rent can also be canceled there. No refund is provided in case of an early cancellation.
Virtual Hosting Is the Best Solution for the Automated Trading!
The benefits of the virtual hosting service are evident:
- fast and easy way to receive a virtual server directly from the client terminal;
- ability to examine and test the service within free 1440 minutes that can be used in parts;
- ready-made and configured virtual terminal;
- flexible service plans with discounts depending on a rental period duration;
- ability to select location with the minimum network latency to your broker's trade server;
- you can easily pay rental fees using your unified MQL5.community account. Ability to pay from a trading account is underway.
What do traders need to be able to perform the automated trading round-the-clock or copy trading signals? They need transparent and intuitive service that ensures reliable terminal operation with a guaranteed connection to a trade server and requires minimum efforts from a user.
Virtual hosting solves these issues - simply choose a virtual server and use your free 1440 minutes to check it out!
Translated from Russian by MetaQuotes Software Corp.
Original article: https://www.mql5.com/ru/articles/994