title: "MetaTrader 5 Agents & AWS EC2 (VPS/VDS) for Forex, CFD and Futures" pgtitle: MetaTrader 5 Agents & AWS EC2 description: Using MetaTrader 5 (MT5) Agents on Amazon servers VPS/VDS. This is an excellent option for checking the trading strategy for the currency and stock markets Forex, CFD and Futures.
Using MetaTrader 5 (MT5) Agents on Amazon servers VPS/VDS. This is an excellent option for checking the trading strategy for the currency and stock markets Forex, CFD and Futures.
MetaTrader 4 (MT4) does not have Test Agents.
The difference from the use of the Agents cloud:
- Fixed price per hour and a fixed number of processor cores.
- Ability to use local files from FILE_COMMON.
- Ability to use OpenCL on the CPU (and GPU, if the instance allows).
- Upload large files needed for testing, you can through the bucket S3.
- Possibility of using dynamic libraries (DLL) is possible.
Agents are run with the flag "/local" as with local use.
The cost of using Amazon servers can be much more economical than using the Cloud of Agents. Calculation of the cost of the Cloud occurs by a mysterious formula, so it is very difficult to estimate the cost of full optimization.
Prices for spot-instances are available here{:target="_blank"}.
But after registration, the table is available that can be obtained by creating a spot-instance{:target="_blank"} (blue "Request Spot Instances" button) and clicking on the gray "Change instance type" button.
There is a special instance:
cc2.8xlarge CPUs 32 Memory 60.5GiB SSD 4 x 840 GB
The price ranges from $0.20 to $0.30 per hour, which corresponds to instances with 16 CPUs. This instance has an out-of-date status and can periodically disappear from the list of available instances. It makes sense to view all 4 US regions for its availability before ordering the instance.
The cc2.8xlarge is ideal for Agents.
It makes sense in four US regions to create a rule for Security Groups{:target="_blank"}.
N. Virginia{:target="_blank"},
Ohio{:target="_blank"},
N. California{:target="_blank"},
Oregon{:target="_blank"}
You need to open ports for access from outside. Since the server will exist for a limited time and will not be used for public purposes. You can not bother with the choice of ports and open them all, although this is contrary to security rules.
You need to create a Role with access rights to the bucket S3.
- Go to the Role Management section{:target="_blank"} and click on the blue "Create role" button.
- Select the EC2 service and click on the blue "Next" button.
- The script for launching Agents only downloads files from the S3 bucket, so just select "AmazonS3ReadOnlyAccess" and click on the blue "Next" button.
- Now you need to set the Role name and click on the blue "Create role" button.
You can create access keys for using programs to upload files to the S3 bucket. These keys also allow you to receive spot prices from all regions in AmazonUtils{:target="_blank"}. Forgotten access keys in a source code can cause trouble{:target="_blank"} (RU).
- First you need to create an S3 bucket with the default settings.{:target="_blank"}
- Create a folder "MetaQuotes".
- Download the file "c:\Program Files\MetaTrader 5\metatester64.exe" to the folder "MetaQuotes".
- Download the necessary files from the folder "c:\Users\USER\AppData\Roaming\MetaQuotes\Terminal\Common\Files" to "MetaQuotes/Terminal/Common/Files/".
The download should be done for each region in which the Agents are scheduled to be launched.
In the Spot Requests{:target="_blank"} click on the blue "Request Spot Instances" button.
A new request design will appear, in which all the settings are hidden under "Additional configurations". You can switch to the old design at the very bottom of the page by "Previous version of Request Spot Instances".
In the new design, select "Defined duration workloads".
The script I created for running Agents is designed for Ubuntu.
I usually choose cc2.8xlarge with a built-in SSD on 840GB. It is often a great discount, because this instance of the previous generation, but for Agents it is great.
If the instance has built-in disk space, then the number of gigabytes for EBS can be set at a minimum (paid separately).
All Agents are run in "/mnt". The first partition of the built-in disk is automatically mounted in this folder. If the size of the first partition is not enough, then you need to take an instance only with EBS or edit the script. Add a second partition does not make sense, because it will be the last.
Set the rule for opening ports in "Security groups".
If you use a pre-created role in the "IAM instance profile", then the script does not need to specify the key to Amazon.
Open the aws_ubuntu_user_data.sh{:target="_blank"} and paste the contents into "User data".
- Hours=1 - limits the work of the instance by the number of hours, because the payment is hourly.
- agentStartPort=5000 - the start port for the 1st Agent.
- agentPassword=amazon99 - password for access to Agents.
- bucket= - name of the bucket where the files needed for the test are located.
- If the role is not specified, you will have to specify access keys to download files from the S3 bucket.
After clicking on the blue button "Launch" a request to create an instance.
Instance can be issued by Amazon with a delay, so you need to update the page until it appears in the "Instances" list.
After that, you can go to the instance page and click on the gray "Connect" button to get the IP.
Now you can add Agents to the list for optimization in MetaTrader 5 (MT5).
The script needs time (approximately 5 minutes) to run Agents in Ubuntu.
On all questions to address in this topic.{:target="_blank"}