Log in to the trading account - MetaTrader 5 library | MT5 EA download - MetaTrader 5 resources
The “ LoginTradingAccount.mqh ” library allows automating the process of connecting to a trading server.
The EA checks the connection to the trading server (TERMINAL_CONNECTED identifier) every 12 seconds in the OnTimer() function. If the connection status is "0", the library is called :
//+------------------------------------------------------------------+ //| TestAccountDisable.mq5 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #Property Copyright "Copyright 2016, MetaQuotes Software Corp." #Property association "https://www.mql5.com" # Property version "1.00" #include <login to trading account.mqh> //+----------------------------------------------------------------------------------+ //|Expert initialization function | //+------------------------------------------------------------------+ Integer initialization () { //--- Create a timer event to set the timer ( 12 ); you //--- return ( initialization successful ); } //+------------------------------------------------------------------+ //|Expert to initialize function | //+------------------------------------------------------------------+ Blank solution initialization ( constant integer reason) { //--- Destroy timer event to terminate timer (); } //+------------------------------------------------------------------+ //|Expert check function | //+------------------------------------------------------------------+ Blank check () { you//--- } //+----------------------------------------------------------------------------------+ //|Timer function | //+------------------------------------------------------------------+ blank timer () { you // --- static boolean cleaner = false ; if (!cleaner) { Long result = terminal information integer ( TERMINAL_CONNECTED terminal is connected ); Comment ( "TERMINAL_CONNECTED:" , integer to string (result)); if (result == 0 ) login trading account(); } Other comments ( "" ); Cleaner =! detergent; } //+------------------------------------------------------------------+
The "TestAccountDisable.mq5" sample file is attached at the end of the instructions.
Attachment download
📎logintotradeaccount.mqh (6.98 KB)
📎 testaccountdisable.mq5 (1.98 KB)
Source: MQL5 #16049
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •