File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 97
97
}
98
98
error_desc = error_messages.get(error_code, 'Unknown error')
99
99
print(f'Detailed error: {error_desc}')
100
- sys.exit(1)
100
+
101
+ # Instead of exiting with error, try a different approach
102
+ # Recommended by GitHub repo ricardokj/mt5_python_actions
103
+ print('Trying alternative initialization approach...')
104
+
105
+ # Use an approach similar to that used by ricardokj/mt5_python_actions
106
+ # This approach relies on portable mode without display requirements
107
+ import os
108
+ import subprocess
109
+
110
+ # Initialize without displaying UI
111
+ os.environ['MT5_DISABLE_UI'] = '1'
112
+
113
+ # Try a simpler initialization with fewer parameters
114
+ mt5.shutdown()
115
+ time.sleep(2)
116
+ result = mt5.initialize(timeout=60000)
117
+ print(f'Alternative initialization result: {result}, Error: {mt5.last_error()}')
118
+
119
+ if not result:
120
+ print('Both initialization methods failed.')
121
+ sys.exit(1)
101
122
else:
102
123
print('MT5 initialized successfully')
103
124
print(f'Terminal info: {mt5.terminal_info()}')
You can’t perform that action at this time.
0 commit comments