File size: 981 Bytes
903318b
25cf2f8
 
 
 
 
 
 
60e5269
25cf2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

import streamlit as st
from datetime import datetime

# Streamlit app title
st.title("MetaTrader 5 Login")

# Streamlit input fields
login = st.number_input("Login ID", step=1)
password = st.text_input("Password", type="password")
server = st.text_input("Server")

# Button to initialize and log in
if st.button("Initialize and Log In"):
    # Initialize MetaTrader 5
    initialized = mt.initialize()
    if initialized:
        st.success("MetaTrader 5 initialized successfully.")
        
        # Attempt to log in
        logged_in = mt.login(login=int(login), password=password, server=server)
        if logged_in:
            st.success(f"Logged in successfully as {login}.")
        else:
            st.error("Failed to log in. Please check your credentials.")
    else:
        st.error("Failed to initialize MetaTrader 5.")

# Button to shutdown MetaTrader 5
if st.button("Shutdown MetaTrader 5"):
    mt.shutdown()
    st.success("MetaTrader 5 has been shut down.")