diff --git a/Metatrader/start.sh b/Metatrader/start.sh index 8c205cc..77d77e3 100644 --- a/Metatrader/start.sh +++ b/Metatrader/start.sh @@ -7,6 +7,7 @@ WINEDEBUG='-all' wine_executable="wine" metatrader_version="5.0.36" mt5server_port="8001" +MT5_CMD_OPTIONS="${MT5_CMD_OPTIONS:-}" mono_url="https://dl.winehq.org/wine/wine-mono/10.3.0/wine-mono-10.3.0-x86.msi" python_url="https://www.python.org/ftp/python/3.9.13/python-3.9.13.exe" mt5setup_url="https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" @@ -70,7 +71,7 @@ fi # Recheck if MetaTrader 5 is installed if [ -e "$mt5file" ]; then show_message "[4/7] File $mt5file is installed. Running MT5..." - $wine_executable "$mt5file" & + $wine_executable "$mt5file" $MT5_CMD_OPTIONS & else show_message "[4/7] File $mt5file is not installed. MT5 cannot be run." fi diff --git a/README.md b/README.md index 8547a6b..6f1663e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This project provides a Docker image for running MetaTrader5 with remote access - Run MetaTrader5 in an isolated environment. - Remote access to MetaTrader5 interface via an integrated VNC client accessible through a web browser. - Built on the reliable and secure [KasmVNC](https://github.com/kasmtech/KasmVNC) project. -- RPyC server for remote access to Python MetaTrader Library from Windows or Linux using https://github.com/lucas-campagna/mt5linux +- RPyC server for remote access to Python MetaTrader Library from Windows or Linux using ![MetaTrader5 running inside container and controlled through web browser](https://imgur.com/v6Hm9pa.png) @@ -18,7 +18,7 @@ Due to some compatibility issued, version 2 has switched its base from Alpine to If you just need to run Metatrader for running your MQL5 programs without any Python programming I recommend to go on using version 1.0. MetaTrader program is updated independently from image so you will always have latest MT5 version. ------------ +---------- ## Requirements @@ -28,17 +28,20 @@ If you just need to run Metatrader for running your MQL5 programs without any Py ## Usage from repository 1. Clone this repository: + ```bash git clone https://github.com/gmag11/MetaTrader5-Docker-Image cd MetaTrader5-Docker-Image ``` 2. Build the Docker image: + ```bash docker build -t mt5 . ``` 3. Run the Docker image: + ```bash docker run -d -p 3000:3000 -p 8001:8001 -v config:/config mt5 ``` @@ -50,12 +53,14 @@ On first run it may take a few minutes to get everything installed and running. ## Usage with docker compose with image form Docker Registry (preferred way) 1. Create a folder in a path where you have permission. For instance in your home. + ```bash mkdir MT5 cd MT5 ``` 2. Create `docker-compose.yaml` file. + ```bash nano docker-compose.yaml ``` @@ -87,12 +92,37 @@ image: gmag11/metatrader5_vnc by this one - ```yaml image: gmag11/metatrader5_vnc:1.1 ``` -3. Start the container +---------- + +**Notice**: Due to Windows permission management, if you are using windows use Docker managed volume instead of bind mount. Use this compose file instead: + +```yaml +version: '3' +services: + mt5: + image: gmag11/metatrader5_vnc + container_name: mt5 + volumes: + - mt5_config:/config + ports: + - 3000:3000 + - 8001:8001 + environment: + - CUSTOM_USER= + - PASSWORD= + +volumes: + mt5_config: +``` + +---------- + +1. Start the container + ```bash docker compose up -d ``` @@ -100,14 +130,16 @@ docker compose up -d In some systems `docker compose` command does not exists. Try to use `docker-compose up -d` instead. 4. Connect to web interface - Start your browser pointing http://:3000 + +Start your browser pointing `http://:3000` On first run it may take a few minutes to get everything installed and running. Normally it takes less than 5 minutes. You don't need to do anything. All installation process is automatic and you should end up with MetaTrader5 running in your web session. ## Where to place MQ5 and EX5 files -In the case you want to run your own MQL5 bots inside the container you can find MQL5 folder structure in -``` +In the case you want to run your own MQL5 bots inside the container you can find MQL5 folder structure in + +```bash config/.wine/drive_c/Program Files/MetaTrader 5/MQL5 ``` @@ -134,7 +166,7 @@ print(mt5.version()) Output should be something like this: -``` +```python (mt5linux) linux:~/$ python3 Python 3.10.13 (main, Dec 26 2023, 20:21:41) [GCC 13.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. @@ -148,14 +180,58 @@ True ``` ## Configuration -The port configuration can be adjusted as per the instructions in the KasmVNC repository. Any additional configuration or environment variables needed to customize MetaTrader5 and KasmVNC running settings should be described here. + +The port configuration can be adjusted as per the instructions in the KasmVNC repository. + +### MetaTrader 5 Command Line Options + +You can pass command line options to MetaTrader 5 using the `MT5_CMD_OPTIONS` environment variable. This is useful for custom configurations, tester modes, or other MetaTrader command line parameters. + +Example using docker-compose: + +```yaml +version: '3' +services: + mt5: + image: gmag11/metatrader5_vnc + container_name: mt5 + volumes: + - mt5_config:/config + ports: + - 3000:3000 + - 8001:8001 + environment: + - CUSTOM_USER= + - PASSWORD= + - MT5_CMD_OPTIONS=/config:C:\\customized_for_tester_etc.ini + +volumes: + mt5_config: +``` + +Example using docker run: + +```bash +docker run -d -p 3000:3000 -p 8001:8001 \ + -e MT5_CMD_OPTIONS="/config:C:\\customized_for_tester_etc.ini" \ + -v mt5_config:/config \ + gmag11/metatrader5_vnc +``` + +Common MetaTrader 5 command line options: + +- `/config:` - Use a specific configuration file +- `/login:` - Automatically login to specified account + +For a complete list of available options, refer to the [MetaTrader 5 documentation](https://www.metatrader5.com/en/terminal/help/start_advanced/start). ## Contributions + Feel free to contribute to this project. All contributions are welcome. Open an issue or create a pull request. ## License -This project is licensed under the terms of the [MIT license](https://opensource.org/license/mit/). +This project is licensed under the terms of the [MIT license](https://opensource.org/license/mit/). The [**KasmVNC**](https://github.com/kasmtech/KasmVNC) project is licensed under the [GNU General Public License v2.0 (GPLv2)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html). You can check the license details of KasmVNC [here](https://github.com/kasmtech/KasmVNC/blob/master/LICENSE.TXT). @@ -163,5 +239,6 @@ The [**KasmVNC**](https://github.com/kasmtech/KasmVNC) project is licensed under Please ensure to comply with the terms and conditions of the licenses while using or modifying this project. -# Acknowledgments +## Acknowledgments + Acknowledgments to the [KasmVNC](https://github.com/kasmtech/KasmVNC) project, [KasmVNC Base Image from LinuxServer](https://github.com/linuxserver/docker-baseimage-kasmvnc/tree/master), [mt5linux library](https://github.com/lucas-campagna/mt5linux) and any other project or individual that contributed to the realization of this project. diff --git a/docker-compose-windows.yaml b/docker-compose-windows.yaml new file mode 100644 index 0000000..7b497a1 --- /dev/null +++ b/docker-compose-windows.yaml @@ -0,0 +1,14 @@ +services: + mt5: + build: . + image: gmag11/metatrader5_vnc + container_name: mt5 + volumes: + - mt5-config:/config + ports: + - 3000:3000 + - 8001:8001 + env_file: + - .env +volumes: + mt5-config: