@@ -22,10 +22,10 @@ jobs:
2222 run : |
2323 # Download MT5 setup
2424 Invoke-WebRequest -Uri "https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe" -OutFile mt5setup.exe
25-
25+
2626 # Install MT5 silently
2727 Start-Process -FilePath .\mt5setup.exe -ArgumentList "/auto" -Wait
28-
28+
2929 # Verify installation
3030 $mtPath = "C:\Program Files\MetaTrader 5\terminal64.exe"
3131 if (Test-Path $mtPath) {
@@ -45,52 +45,12 @@ jobs:
4545 # Kill any existing MT5 instances
4646 taskkill /F /IM terminal64.exe 2>$null
4747 Start-Sleep -Seconds 3
48-
48+
4949 # Start MT5 with the /desktop parameter as suggested in MQL5 forum
5050 $process = Start-Process -FilePath "C:\Program Files\MetaTrader 5\terminal64.exe" -ArgumentList "/portable", "/desktop" -PassThru
5151 $processId = $process.Id
5252 Write-Host "Started MetaTrader 5 terminal with PID $processId using /desktop parameter"
5353 Start-Sleep -Seconds 30
54-
55- - name : Test MT5 Initialization
56- run : |
57- # Python script for testing MT5 initialization
58- $script = @'
59- import sys
60- import time
61- import MetaTrader5 as mt5
62-
63- print(f"MetaTrader5 package version : {mt5.__version__}")
64- path = r"C:\Program Files\MetaTrader 5\terminal64.exe"
65-
66- # Try initialization with the approach from the forum
67- print("Attempting MT5 initialization...")
68- result = mt5.initialize(path=path, timeout=60000)
69- error = mt5.last_error()
70- print(f"Result : {result}, Error code: {error}")
71-
72- if result :
73- print("Successfully initialized MetaTrader 5!")
74- # Get terminal info
75- terminal_info = mt5.terminal_info()
76- if terminal_info :
77- print(f"Terminal info - Path : {terminal_info.path}")
78- print(f"Terminal connected : {getattr(terminal_info, 'connected', 'N/A')}")
79-
80- # Shut down properly
81- mt5.shutdown()
82- else :
83- print("Failed to initialize MetaTrader 5")
84-
85- # Always exit with success for CI
86- sys.exit(0)
87- ' @
88-
89- # Save script to temporary file
90- $script | Out-File -FilePath "test_mt5.py" -Encoding utf8
91-
92- # Run the test
93- python test_mt5.py
94-
95- # Always continue build
96- exit 0
54+ # Start MT5 with the /desktop parameter as suggested in MQL5 forum
55+ $process = Start-Process -FilePath "C:\Program Files\MetaTrader 5\terminal64.exe" -ArgumentList "/portable", "/desktop" -PassThru
56+ run : python -c "import sys, MetaTrader5 as mt5; print(f'MT5 version: {mt5.__version__}'); print('Initializing...'); result = mt5.initialize(path=r'C:\\Program Files\\MetaTrader 5\\terminal64.exe', timeout=60000); print(f'Result: {result}, Error: {mt5.last_error()}'); sys.exit(0)"
0 commit comments