Welcome to Blog No 5 in this miniseries of 10 daily blogs in which I will exploit MT4GUIs functionalities.
I hope you find it both interesting as well as valuable!
Sincerely
Thommy Tikka
Isn’t it frustrating when you do not have the relevant Internet links available when needed!?
Or the links to your favorite tools websites or the support mail address to the same!?
Todays code will show you three ways to use links within MT4 (with MT4GUI functions).
// mt4gui-LinkHandling.mq4 // Created by Thommy Tikka (thommy_tikka@hotmail.com) // Version 0.1, 20130405 // Include library file with common functions for mt4gui #include <mt4gui.mqh> // Declare global variables int hwnd = 0; int menuCalendar, menuSubCalendar1, menuSubCalendar2; int menuNews, menuSubNews1, menuSubNews2, menuSubNews3; int menuNTools; int menuNSupport; int linkBtn; // Declare variables that are adjustable in the EA properties inputs extern string MT4MENUITEMS = "--- Choose MT4 main menu calendar/news links ---", CalendarHeader1 = "FxStreetCal", CalendarLink1 = "http://www.fxstreet.com/fundamental/economic-calendar/#", CalendarHeader2 = "ForexFactoryCal", CalendarLink2 = "http://www.forexfactory.com/calendar.php", NewsHeader1 = "FxStreetNews", NewsLink1 = "http://www.fxstreet.com/news/", NewsHeader2 = "ForexFactoryNews", NewsLink2 = "http://www.forexfactory.com/news.php", NewsHeader3 = "TalkingForex", NewsLink3 = "http://talking-forex.com/live.html"; extern string MT4MENUCOLORS = "--- MT4 menu color settings ---"; extern color MT4CalendarMenuBgColor = Lime, MT4SubCalendar1MenuBgColor = Blue, MT4SubCalendar1MenuTextColor = White, MT4NewsMenuBgColor = Aqua, MT4SubNews3MenuBgColor = Red, MT4SubNews3MenuTextColor = White; extern string MT4NAVIGATORITEMS = "--- Choose MT4 navigator menu tools/support links ---"; extern string ToolsHeader1 = "MT4GUI Home", ToolsLink1 = "http://www.mt4gui.com/", ToolsHeader2 = "MQLLock Home", ToolsLink2 = "https://mqllock.com/", SupportHeader1 = "BlogSupport E-mail", SupportLink1 = "mailto:thommy_tikka@hotmail.com"; extern string MT4GUIBUTTONITEMS = "--- Add caption and link to MT4GUI button ---", LinkBtnCaption = "Sunshine", LinkBtnLink = "http://en.wikipedia.org/wiki/Tenerife"; // MT4 function called during the module initialization //+-------------------------------------------------------------------------------------------+ int init() { hwnd = WindowHandle(Symbol(),Period()); guiRemoveAll(hwnd); guiLinkRemove(hwnd); // Add menu items Calendar & News to MT4 main menu BuildMT4Menu(); // Add menu items Tools & Support to MT4 navigator menu BuildMT4NavigatorMenu(); // Add Link button to chart CreateLinkBtn(); return(0); } // MT4 function called during deinitialization of the module //+-------------------------------------------------------------------------------------------+ int deinit() { // Very important to cleanup and remove all gui items from chart if (hwnd>0) guiRemoveAll(hwnd); guiCleanup(hwnd); guiLinkRemove(hwnd); return(0); } // MT4 function called on every MT4 tick //+-------------------------------------------------------------------------------------------+ int start() { // Call function ManageMT4MenuEvents on every MT4 tick ManageMT4MenuEvents(); } // MT4GUI functions to capture MT4 News Menu Events //+-------------------------------------------------------------------------------------------+ void ManageMT4MenuEvents() { if (guiIsMenuClicked (hwnd, menuSubNews1)) guiOpenBrowser (NewsLink1); if (guiIsMenuClicked (hwnd, menuSubNews2)) guiOpenBrowser (NewsLink2); if (guiIsMenuClicked (hwnd, menuSubNews3)) guiOpenBrowser (NewsLink3); if (guiIsMenuClicked (hwnd, menuSubCalendar1)) guiOpenBrowser (CalendarLink1); if (guiIsMenuClicked (hwnd, menuSubCalendar2)) guiOpenBrowser (CalendarLink2); if (guiIsClicked (hwnd, linkBtn)) guiOpenBrowser (LinkBtnLink); } // MT4GUI functions to create MT4 Menu //+-------------------------------------------------------------------------------------------+ void BuildMT4Menu() { // Add Calendar menu to MT4 menu menuCalendar = guiAddMenu(hwnd, "Calendar", 0, 0); // Add Calendar sub-menus menuSubCalendar1 = guiAddMenu(hwnd, CalendarHeader1, menuCalendar, 0); menuSubCalendar2 = guiAddMenu(hwnd, CalendarHeader2, menuCalendar, 0); // Add "look and feel" to calendar menu items guiSetMenuBgColor(hwnd, menuCalendar, MT4CalendarMenuBgColor); guiSetMenuBgColor(hwnd, menuSubCalendar1, MT4SubCalendar1MenuBgColor); guiSetMenuTextColor(hwnd, menuSubCalendar1, MT4SubCalendar1MenuTextColor); // Add News menu to MT4 menu menuNews = guiAddMenu(hwnd, "News", 0, 0); // Add News sub-menus menuSubNews1 = guiAddMenu(hwnd, NewsHeader1, menuNews,0); menuSubNews2 = guiAddMenu(hwnd, NewsHeader2, menuNews,0); menuSubNews3 = guiAddMenu(hwnd, NewsHeader3, menuNews,0); // Add "look and feel" to news menu items guiSetMenuBgColor(hwnd, menuNews, MT4NewsMenuBgColor); guiSetMenuBgColor(hwnd, menuSubNews3, MT4SubNews3MenuBgColor); guiSetMenuTextColor(hwnd, menuSubNews3, MT4SubNews3MenuTextColor); } // MT4GUI functions to create MT4 Navigator Menu //+-------------------------------------------------------------------------------------------+ void BuildMT4NavigatorMenu() { // Add Tools menu to Navigator menu + 2 tools sub-links menuNTools = guiLinkAdd(hwnd, 0, "Tools",""); guiLinkAdd(hwnd, menuNTools, ToolsHeader1, ToolsLink1); guiLinkAdd(hwnd, menuNTools, ToolsHeader2, ToolsLink2); // Add Support menu to Navigator menu + 1 support sub-link menuNSupport = guiLinkAdd(hwnd, 0, "Support",""); guiLinkAdd(hwnd, menuNSupport, SupportHeader1, SupportLink1); } // MT4GUI functions to create Button //+-------------------------------------------------------------------------------------------+ void CreateLinkBtn() { // Position and size of the Link button ,x ,y ,a ,b (x, y = position from top left corner. a, b = size of button) linkBtn = guiAdd(hwnd, "button", 10, 30, 100, 100, ""); // Link button rounded corners radius guiSetBorderRadius(hwnd, linkBtn, 100); // Link button Border color guiSetBorderColor(hwnd, linkBtn, Yellow); // Link button Background color guiSetBgColor(hwnd, linkBtn, Red); // Link button Text color guiSetTextColor(hwnd, linkBtn, Yellow); // Add caption to Link button guiSetText(hwnd, linkBtn, LinkBtnCaption, 25, "Arial Bold"); }
Monday I will show you how you can use MT4GUI functionality for “IN-trade”-actions!
Thats all folks and have a really nice weekend!
You must be logged in to post a comment.