Disconnected Sound Alert - MetaTrader 5 Expert | MT5 EA Download - MetaTrader 5 Resources
This utility is a simple example of adding a sound alert when connecting/disconnecting
Add sound wav files in the MQL5\Files\Sounds folder
Copy the code and compile the EA utility. There are comment lines in the attachment, which cannot be uploaded because of the use of #resource.
//+------------------------------------------------------------------+ //| Connect_Disconnect_Sound_Alert.mq5 | //| Copyright 2024, Rajesh Kumar Knight | //| https://www.mql5.com/en/users/rajeshnait/seller | //+------------------------------------------------------------------+ #Property Copyright "Copyright 2024, Rajesh Kumar Knight" #Property association "https://www.mql5.com/en/users/rajeshnait/seller" # Property version "1.00" #Include <Trading/TerminalInfo.mqh> Boolean First = True ; Boolean Now_IsConnected = False ; Boolean Pre_IsConnected = True ; DateTimeConnect_Start = 0 , Connect_Stop= 0 ; CTerminalInfo terminal information; //--- sound file #Resource "\\File\\Sound\\CONNECTED.wav" #Resource "\\File\\Sound\\DISCONNECTED.wav" //+------------------------------------------------------------------+ //|Expert initialization function | //+------------------------------------------------------------------+ Integer initialization () { //--- Reset the last error (); Although (! stop ()) { Pre_IsConnected = Now_IsConnected; Now_IsConnected =terminalInfo.IsConnected(); if (first){ Pre_IsConnected = !Now_IsConnected; } if (Now_IsConnected != Pre_IsConnected) { if (Now_IsConnected) { connect_start = timelocal (); if (! first of) { if (! play sound ( "::file\\sound\\DISCONNECTED.wav" )) print ( "Error: " , get the last error ()); } if ( stopped () ) { rest ; } if (! play sound ( "::file\\sound\\CONNECTED.wav" )) print ( "Error: " , get the last error ()); } other { connect_stop = timelocal (); if (! first of) { if (! play sound ( "::file\\sound\\CONNECTED.wav" )) print ( "Error: " , get the last error ()); } if ( stopped () ) { rest ; } if (! play sound ( "::file\\sound\\DISCONNECTED.wav" )) print ( "Error: " , get the last error ()); } } first = wrong ; sleep ( 1000 ); } //--- return ( initialization successful ); } //+----------------------------------------------------------------------+
Attachment download
📎 connect_disconnect_sound_alert.mq5 (2.45 KB)
Source: MQL5 #47846
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •