DAY5: LinkHandling

Home / Howtos / DAY5: LinkHandling

DAY5: LinkHandling within MT4

Introduction

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

DAY5: Objective

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).

DAY5: Functions covered

MT4GUI

  • MT4GUI MT4 main menu functions (http links of your choice)
  • MT4GUI MT4 navigator links (http links of your choice)
  • MT4GUI button (http link of your choice)
  • Look and feel (Size, color, positioning etc of GUI & menu objects)
  • MT4 (MQL4)

  • EA property inputs (set default headers/links, GUI/menu colors, button captions etc)
  • CODEBASE:

    // 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");
    }
    

    VIDEOCLIP:

    Monday I will show you how you can use MT4GUI functionality for “IN-trade”-actions!

    Thats all folks and have a really nice weekend!

    4 Comments Responses to DAY5: LinkHandling
    Robertkit2017-01-20 15:11:46Reply
    The best fitness tip for building up your arms is to work opposite muscles in opposite sets of each other. The best example would be to work the triceps and then the biceps. Each has the opportunity to rest while the other is being worked. This minimizes your time and maximizes your workout. https://www.acheterviagrafr24.com/
    pletcherbcu2016-04-21 17:41:47Reply
    =
    ganar dinero gratis2013-04-12 09:08:58Reply
    I want to to thank you for this great read!! I absolutely loved every little bit of it. I have you book marked to check out new stuff you post…
    Thommy Tikka2013-04-12 09:41:29Reply
    Hi, Thanks for positive comment, it is always a pleasure to see that someone appreciate the work! Thommy
    Mook2013-04-09 03:46:18Reply
    Great add-on for MT4 and your tutorials are even better.... Your time permitting, could you pls do a tutorial on how to convert a script with several variable inputs for use with MT4 Gui - as example order entry script, so that there are three lot sizes available as radio buttons, buy / sell at Market and each three different SL and TP Very much appreciated Mook
    Thommy Tikka2013-04-12 09:53:48Reply
    Hi, Nice to see that you have found an area where you can benefit from MT4GUI and its functions! Regarding my Blogs, I try to cover the basic functions within MT4GUI in a practical sense so that readers can, based on the Blog and the Tutorials/Examples in the Documentation area start to build their own MT4GUI-experience. If you have more specific needs I recommend you to contact a MQL4-developer with MT4GUI experience. I can help you out as well, on a consultancy basis. Thommy
    Leave a comment