Howtos

Home / Archive by category "Howtos"

Category Archive: Howtos

  1. DAY7: PRE-Trade Management

    2 Comments

    DAY7: PRE-Trade Management

    Introduction

    Welcome to Blog No 7 in this miniseries of 10 blogs in which I will exploit MT4GUIs functionalities.

    I hope you find it both interesting as well as valuable!

    Sincerely

    Thommy Tikka

    DAY7: Objective

    Risk- and money management are important “PRE-trade” components to handle to achieve success in trading.
    Fixed lot size or risk based lot size?
    Risk based on Account balance or on Equity balance?
    The choice is yours when you use following piece of code!

    DAY7: Functions covered

    MT4GUI

  2. MT4GUI checkbox (enable/disable PRE-trade button panel)
  3. MT4GUI button (switch between Fixed/Risk based lot size)
  4. MT4GUI button (enable/disable movable visual SLline
  5. Look and feel (Size, color, positioning etc of GUI objects)
  6. MT4 (MQL4)

  7. Usage of horizontal line (movable) for SL
  8. EA property inputs (set default Risk/MoneyMgmt settings, SL-level and GUI panel Y-position)
  9. Calculate Lot size based in preset inputs
  10. Set PipPoint based on Broker digits
  11. CODEBASE:

    // mt4gui-PRETradeManagement.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com) 
    // Version 0.1, 20130412
    
    // Include library file with common functions for mt4gui
    #include <mt4gui.mqh>
    
    // Declare global variables
    int hwnd = 0;
    int enablePRETradeBtn, moneyMgmtBtn, visualSLLineBtn;
    int gUIXPos;
    double actualSLPrice, actualSLPips;
    double usePoint, lotSize=0;
    string sLStatus="Default", lSStatus="Fixed";
    
    //Set default PRE-trade variables, possible to change in the EA Properties
    extern string     MONEYMANAGEMENTSETTINGS      = "----- Money/Risk Management -----";                 
    extern bool       MoneyManagementRiskInPercent = false, // Money Management, if true uses Risk Percentage, if false uses Lot Size
                      RiskBasedOnAccountBalance    = true; // Risk base on AccountBalance or AccountEquity
    extern double     RiskPercent                  = 10, // Risk Percentage, percent amount of account to risk when Money Management set to true, overrides Lot Size
                      FixedLotSize                 = 0.1,
                      DefaultStopLoss              = 10;
    
    extern string     GUIPOSITION                  = "----- GUI Position -----";
               
    // Y-Position the guiButtons
    extern int        GUIYPos                      = 50;       
                      
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());	
    	guiRemoveAll(hwnd);	
    	
    	// Automatic X-Postion to the right 
       gUIXPos = guiGetChartWidth(hwnd)-200;
    	
    	// Delete visual lines from chart
    	DeleteVisualSLLine();
    
       // Add screenshot button to chart function call
       CreateButtons();
       
       // Disable all gui Buttons
       ChangePRETradeState();
      
       // Set PointValue
       usePoint = PipPoint(Symbol());
       
       // Set default actualSL based on EA properties
       actualSLPips = DefaultStopLoss;
      
       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);
       
       // Delete visual lines from chart
       DeleteVisualSLLine();
       
       // Remove eventual Comment
       Comment ("");
       
       return(0);
      }
    
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
       
       // Call function Move SL based on line
       if (!ObjectFind("INT.SLLine")==-1) ChangeSL();
       
       // Call function to calculate lotSize
       CalculateLotSize();   
       
       // Show SL and lotSize¨
       if (actualSLPrice!=0) sLStatus="Actual"; 
       if (MoneyManagementRiskInPercent  && RiskBasedOnAccountBalance) lSStatus="AccountBalance riskbased LotSize: ";
       if (MoneyManagementRiskInPercent  && !RiskBasedOnAccountBalance) lSStatus="EquityBalance riskbased LotSize: ";
       if (!MoneyManagementRiskInPercent) lSStatus="Fixed LotSize: "; 
       Comment (sLStatus+" SL Pips: "+DoubleToStr(actualSLPips,1)+"\n"+lSStatus+DoubleToStr(lotSize,5));
      }
    
    
    // MT4GUI functions to create Button
    //+-------------------------------------------------------------------------------------------+
    void CreateButtons()
    {
    	// Position and size of the button ,x ,y ,a ,b (x, y = position from top left corner. a, b = size of button)
    	enablePRETradeBtn	= guiAdd(hwnd, "checkbox", gUIXPos, GUIYPos, 140, 30, "Enable PRETrade"); guiSetBgColor(hwnd, enablePRETradeBtn, LightGray);guiSetTextColor(hwnd, enablePRETradeBtn, Black);	
    
    	// Add Risk/Fixed LotSize Btn
    	if (MoneyManagementRiskInPercent)
    	moneyMgmtBtn = guiAdd(hwnd, "button", gUIXPos, GUIYPos+30, 140, 20, "Risk Lots");
    	else moneyMgmtBtn = guiAdd(hwnd, "button", gUIXPos, GUIYPos+30, 140, 20, "Fixed Lots");
    
       // Add visual SL Line Btn
    	visualSLLineBtn = guiAdd(hwnd, "button", gUIXPos, GUIYPos+50, 140, 30, "SL-line");
    }
    
    
    // MT4GUI functions to capture Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {		
    	// If PRE-Trade Btn is checked, enable PRE-Trade actions
    	if (guiIsChecked(hwnd, enablePRETradeBtn)) {guiSetBgColor(hwnd, enablePRETradeBtn, Blue);}
       else {guiSetBgColor(hwnd, enablePRETradeBtn, Aqua);}
       ChangePRETradeState();
    
       // If visualSLLineBtn is clicked call function to draw lines
       if (guiIsClicked(hwnd, visualSLLineBtn)) 
       {
          PlaySound("click.wav"); 
          if (ObjectFind("INT.SLLine")==-1)
             DrawVisualSLLine();
          else
          {
             DeleteVisualSLLine();}
       }
    
       // If moneyMgmtBtn is clicked 
       if (guiIsClicked(hwnd, moneyMgmtBtn)) 
       {
          PlaySound("click.wav");
          if (MoneyManagementRiskInPercent)
          {
             MoneyManagementRiskInPercent=false;
             guiSetText(hwnd, moneyMgmtBtn, "Fixed lots", 16, "Arial Rounded MT Bold");
          }
          else
          {
             MoneyManagementRiskInPercent=true;
             guiSetText(hwnd, moneyMgmtBtn, "Risk lots", 16, "Arial Rounded MT Bold");
          }
       }
    }
    
    
    // MT4 function draw SL visual line
    //+-------------------------------------------------------------------------------------------+
    void DrawVisualSLLine()
    { 
          if (actualSLPrice==0) 
          {
             ObjectCreate("INT.SLLine", OBJ_HLINE, 0, 0, Bid-DefaultStopLoss*usePoint);
             actualSLPips = Bid -(Bid-DefaultStopLoss*usePoint);
          }
          else 
             ObjectCreate("INT.SLLine", OBJ_HLINE, 0, 0, actualSLPrice);
          ObjectSet("INT.SLLine", OBJPROP_STYLE, 1);
          ObjectSet("INT.SLLine", OBJPROP_WIDTH, 1);
          ObjectSet("INT.SLLine", OBJPROP_COLOR, Red);
          ObjectCreate("INT.SLLineLabel", OBJ_TEXT, 0, Time[5], ObjectGet("INT.SLLine", OBJPROP_PRICE1) );
          ObjectSetText("INT.SLLineLabel", "SL", 8, "Arial", Red);
    }
    
    
    // MT4 function delete SL visual line
    //+-------------------------------------------------------------------------------------------+
    void DeleteVisualSLLine()
    {
       for(int i = ObjectsTotal(); i >= 0; i--)
         if(StringSubstr(ObjectName(i), 0, 4) == "INT.")
           ObjectDelete(ObjectName(i));
    }
    
    
    // MT4GUI function, change button states
    //+-------------------------------------------------------------------------------------------+
    void ChangePRETradeState()
    {
       if (guiIsChecked(hwnd,enablePRETradeBtn))
       {
          guiEnable(hwnd, visualSLLineBtn, 1);
          guiSetBgColor(hwnd, visualSLLineBtn, DeepSkyBlue);
          guiEnable(hwnd, moneyMgmtBtn, 1);
          guiSetBgColor(hwnd, moneyMgmtBtn, RoyalBlue);
     
       }
       else
       {
          guiEnable(hwnd, visualSLLineBtn, 0);
          guiSetBgColor(hwnd, visualSLLineBtn, LightGray);
          guiEnable(hwnd, moneyMgmtBtn, 0);
          guiSetBgColor(hwnd, moneyMgmtBtn, LightGray);
          DeleteVisualSLLine();
       }
    }
    
    
    // MT4 function, change SL based on visual line move
    //+-------------------------------------------------------------------------------------------+
    void ChangeSL()
    {
       actualSLPrice = ObjectGet("INT.SLLine", OBJPROP_PRICE1);
       ObjectMove("INT.SLLineLabel", 0, Time[5], ObjectGet("INT.SLLine", OBJPROP_PRICE1));
       actualSLPips = (Bid-actualSLPrice)/usePoint;
    }
    
    
    // MT4 function, Calculate LotSize
    //+-------------------------------------------------------------------------------------------+
    void CalculateLotSize()
    {
       if (MoneyManagementRiskInPercent)
       {
           if (RiskBasedOnAccountBalance)
              double RiskAmount = AccountBalance() * RiskPercent / 100;
           else
              RiskAmount = AccountEquity() * RiskPercent / 100;   
           if (!ObjectFind("INT.SLLine")==-1)
           {
              double CalcLots = RiskAmount / (actualSLPips/usePoint);}
           else
              CalcLots = RiskAmount / DefaultStopLoss*usePoint;
           lotSize = CalcLots;
       }
       else lotSize = FixedLotSize;
    }
    
    
    // MT4 function, Calculate symbols PipPoint
    //+-------------------------------------------------------------------------------------------+
    double PipPoint(string Currency)
    {
    int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
    if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
    else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
    return(CalcPoint);
    }
    

    VIDEOCLIP:

    In next Blog I will show you how you can use MT4GUI functionality in more dynamically changing environment!

    Thats all folks!

  12. DAY6: IN-Trade Management

    Leave a Comment

    DAY6: IN-Trade Management

    Introduction

    Welcome to Blog No 6 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

    DAY6: Objective

    Find it hard to use MT4s built in Terminal for your IN-trade management!?
    Want to have an easy way to move your Stoploss- & Takeprofit levels?
    Lets look how MT4GUI can help you out with quick buttons as well as visual lines!

    DAY6: Functions covered

    MT4GUI

  13. MT4GUI checkbox (enable/disable IN-trade button panel)
  14. MT4GUI buttons (enable/disable visual lines, move TPs and SL-breakeven
  15. Look and feel (Size, color, positioning etc of GUI objects)
  16. MT4 (MQL4)

  17. Usage of different colored horizontal lines (movable) for TP/SL
  18. EA property inputs (set default TP/SL-levels and GUI panel Y-position)
  19. CODEBASE:

    // mt4gui-INTradeManagement.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com) 
    // Version 0.1, 20130409
    
    // Include library file with common functions for mt4gui
    #include <mt4gui.mqh>
    
    // Declare global variables
    int hwnd = 0;
    int enableINTradeBtn, visualLinesBtn, bEBtn;
    int tP1Btn, tP2Btn, tP3Btn;
    int gUIXPos;
    double actualTP, actualSL;
    
    //Set default IN-trade variables, possible to change in the EA Properties
    extern int  DefaultTP = 200, 
                DefaultSL = 100,
                TPLevel1  = 300,
                TPLevel2  = 200,
                TPLevel3  = 100,
                
    // Y-Position the guiButtons
                gUIYPos   = 50;       
    
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());	
    	guiRemoveAll(hwnd);	
    	
    	// Automatic X-Postion to the right 
       gUIXPos = guiGetChartWidth(hwnd)-180;
    	
    	// Delete visual lines from chart
    	DeleteVisualLines();
    
       // Add screenshot button to chart function call
       CreateButtons();
       
       // Disable all gui Buttons
       ChangeINTradeState();
      
       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);
       
       // Delete visual lines from chart
       DeleteVisualLines();
       
       // Remove eventual Comment
       Comment ("");
       
       return(0);
      }
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
       
       // Call function Move TPSL based on lines
       ChangeTPSL();
       
       // Show actual SL and TP settings if not 0  
       if (actualTP!=0 || actualSL!=0) Comment ("Actual TP: "+ DoubleToStr(actualTP,5)+ "\nActual SL: "+DoubleToStr(actualSL,5));
       else Comment ("");
      }
    
    
    // MT4GUI functions to create Button
    //+-------------------------------------------------------------------------------------------+
    void CreateButtons()
    {
    	// Position and size of the button ,x ,y ,a ,b (x, y = position from top left corner. a, b = size of button)
    	enableINTradeBtn	= guiAdd(hwnd, "checkbox", gUIXPos, gUIYPos, 120, 30, "Enable INTrade"); guiSetBgColor(hwnd, enableINTradeBtn, LightGray);guiSetTextColor(hwnd, enableINTradeBtn, Black);	
    
       // Add visual Lines Btn
    	visualLinesBtn = guiAdd(hwnd, "button", gUIXPos, gUIYPos+30, 120, 30, "TP/SL-lines");
    
       // Add BreakEven button
    	bEBtn = guiAdd(hwnd, "button", gUIXPos, gUIYPos+120, 120, 30, "BreakEven");
    	
    	// Add Radio 1-3 for TP-move
       tP1Btn = guiAdd(hwnd, "button", gUIXPos, gUIYPos+60, 120, 20, "TP1 ("+TPLevel1+")"); 
    	tP2Btn = guiAdd(hwnd, "button", gUIXPos, gUIYPos+80, 120, 20, "TP2 ("+TPLevel2+")"); 
    	tP3Btn = guiAdd(hwnd, "button", gUIXPos, gUIYPos+100, 120, 20, "TP3 ("+TPLevel3+")"); 	
    }
    
    
    // MT4GUI functions to capture Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {		
    
    	// If IN-Trade Btn is checked, enable IN-Trade actions
    	if (guiIsChecked(hwnd, enableINTradeBtn)) {guiSetBgColor(hwnd, enableINTradeBtn, Green);}
       else {guiSetBgColor(hwnd, enableINTradeBtn, Aqua);}
       ChangeINTradeState();
    
       // If visualLinesBtn is clicked call function to draw lines
       if (guiIsClicked(hwnd, visualLinesBtn)) 
       {
          PlaySound("click.wav"); 
          if (ObjectFind("INT.TPLine")==-1)
             DrawVisualLines();
          else
             DeleteVisualLines();
       }
    
       // If tPButtons are clicked call function to move TP
       if (guiIsClicked(hwnd, tP1Btn)) {PlaySound("click.wav"); ChangeTP(1);}
       if (guiIsClicked(hwnd, tP2Btn)) {PlaySound("click.wav"); ChangeTP(2);}
       if (guiIsClicked(hwnd, tP3Btn)) {PlaySound("click.wav"); ChangeTP(3);}
    
       // If beBtn is clicked call function to move SL to BreakEven
       if (guiIsClicked(hwnd, bEBtn)) {PlaySound("click.wav"); MoveSLBE();}
    }
    
    
    // MT4 function draw TP/SL visual lines
    //+-------------------------------------------------------------------------------------------+
    void DrawVisualLines()
    {
          if (actualTP==0) ObjectCreate("INT.TPLine", OBJ_HLINE, 0, 0, Bid+DefaultTP*Point);
          else ObjectCreate("INT.TPLine", OBJ_HLINE, 0, 0, actualTP);
          ObjectSet("INT.TPLine", OBJPROP_STYLE, 1);
          ObjectSet("INT.TPLine", OBJPROP_WIDTH, 1);
          ObjectSet("INT.TPLine", OBJPROP_COLOR, Blue);
          ObjectCreate("INT.TPLineLabel", OBJ_TEXT, 0, Time[5], ObjectGet("INT.TPLine", OBJPROP_PRICE1) );
          ObjectSetText("INT.TPLineLabel", "TP", 8, "Arial", Blue);
      
          if (actualSL==0) ObjectCreate("INT.SLLine", OBJ_HLINE, 0, 0, Bid-DefaultSL*Point);
          else ObjectCreate("INT.SLLine", OBJ_HLINE, 0, 0, actualSL);
          ObjectSet("INT.SLLine", OBJPROP_STYLE, 1);
          ObjectSet("INT.SLLine", OBJPROP_WIDTH, 1);
          ObjectSet("INT.SLLine", OBJPROP_COLOR, Red);
          ObjectCreate("INT.SLLineLabel", OBJ_TEXT, 0, Time[5], ObjectGet("INT.SLLine", OBJPROP_PRICE1) );
          ObjectSetText("INT.SLLineLabel", "SL", 8, "Arial", Red);
    }
    
    
    // MT4 function delete TP/SL visual lines
    //+-------------------------------------------------------------------------------------------+
    void DeleteVisualLines()
    {
       for(int i = ObjectsTotal(); i >= 0; i--)
         if(StringSubstr(ObjectName(i), 0, 4) == "INT.")
           ObjectDelete(ObjectName(i));
    }
    
    
    // MT4 function move SL to BreakEven (add your own move SL to BreakEven function here)
    //+-------------------------------------------------------------------------------------------+
    void MoveSLBE()
    {
       actualSL= Bid; //Just an example where the SL & the SL line changes based on variable
       ObjectMove("INT.SLLine", 0, Time[0], actualSL);
    }
    
    
    // MT4GUI function, change button states
    //+-------------------------------------------------------------------------------------------+
    void ChangeINTradeState()
    {
       if (guiIsChecked(hwnd,enableINTradeBtn))
       {
          guiEnable(hwnd, visualLinesBtn, 1);
          guiEnable(hwnd, bEBtn, 1);
          guiEnable(hwnd, tP1Btn, 1);
          guiEnable(hwnd, tP2Btn, 1);
          guiEnable(hwnd, tP3Btn, 1);
          guiSetBgColor(hwnd, bEBtn, LimeGreen);
          guiSetBgColor(hwnd, visualLinesBtn, LimeGreen);
          guiSetBgColor(hwnd, tP1Btn, MediumSpringGreen);
          guiSetBgColor(hwnd, tP2Btn, MediumSpringGreen);  
          guiSetBgColor(hwnd, tP3Btn, MediumSpringGreen);   
       }
       else
       {
          guiEnable(hwnd, visualLinesBtn, 0);
          guiEnable(hwnd, bEBtn, 0);
          guiEnable(hwnd, tP1Btn, 0);
          guiEnable(hwnd, tP2Btn, 0);
          guiEnable(hwnd, tP3Btn, 0);
          guiSetBgColor(hwnd, bEBtn, LightGray);
          guiSetBgColor(hwnd, visualLinesBtn, LightGray);
          guiSetBgColor(hwnd, tP1Btn, LightGray);
          guiSetBgColor(hwnd, tP2Btn, LightGray);  
          guiSetBgColor(hwnd, tP3Btn, LightGray); 
          DeleteVisualLines();
       }
    }
    
    
    // MT4 function, change TP/SL based on visual line move
    //+-------------------------------------------------------------------------------------------+
    void ChangeTPSL()
    {
       if (!ObjectFind("INT.SLLine")==-1) actualSL = ObjectGet("INT.SLLine", OBJPROP_PRICE1);
       if (!ObjectFind("INT.TPLine")==-1) actualTP = ObjectGet("INT.TPLine", OBJPROP_PRICE1);
       ObjectMove("INT.SLLineLabel", 0, Time[5], ObjectGet("INT.SLLine", OBJPROP_PRICE1));
       ObjectMove("INT.TPLineLabel", 0, Time[5], ObjectGet("INT.TPLine", OBJPROP_PRICE1));
    }
    
    
    // MT4 function, change TP based on radio button
    //+-------------------------------------------------------------------------------------------+
    void ChangeTP(int level)
    {
       if (level==1) actualTP = Bid+TPLevel1*Point;
       else if (level==2) actualTP = Bid+TPLevel2*Point;
       else if (level==3) actualTP = Bid+TPLevel3*Point;
       ObjectMove("INT.TPLine", 0, Time[0], actualTP);
    }
    

    VIDEOCLIP:

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

    Thats all folks!

  20. DAY5: LinkHandling

    4 Comments

    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

  21. MT4GUI MT4 main menu functions (http links of your choice)
  22. MT4GUI MT4 navigator links (http links of your choice)
  23. MT4GUI button (http link of your choice)
  24. Look and feel (Size, color, positioning etc of GUI & menu objects)
  25. MT4 (MQL4)

  26. EA property inputs (set default headers/links, GUI/menu colors, button captions etc)
  27. 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!

  28. DAY4: Terminal & Charting Functions

    Leave a Comment

    DAY4: Terminal & Charting functions

    Introduction

    Welcome to Blog No 4 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

    DAY4: Objective

    Ever needed a quick way to switch between pairs or periods in your MT4 chart!?
    Or adjust terminal size, close terminal or chart quickly from a button!?
    Check this out, you are a couple of code blocks from doing it!

    DAY4: Functions covered

    MT4GUI

  29. MT4GUI labels (build a control panel with labels)
  30. MT4GUI radiobutton (to quickly switch between alternatives)
  31. MT4GUI button (Terminal & Chart buttons “control panel” on MT4 chart)
  32. MT4GUI terminal function (get chart width for default GUI positioning)
  33. Look and feel (Size, color, positioning etc of GUI objects)
  34. MT4 (MQL4)

  35. EA property inputs (set default pairs, periods to switch between & GUI colors)
  36. Convert numeric Period to String equivalent
  37. CODEBASE:

    // mt4gui-TerminalChartingFunctions.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com) 
    // Version 0.1, 20130404
    
    // Include library file with common functions for mt4gui
    #include <mt4gui.mqh>
    
    
    // Declare global variables
    int hwnd = 0;
    int menuTerminalBtn, menuChartBtn;
    int controlPanelHeader, controlPanelMenuTerminal, controlPanelMenuChart;
    bool chartMenuOpen=false, terminalMenuOpen=false;
    int RChart1,RChart2,RChart3,RChart4,RChart5,RChart6,RChart7,RChart8;
    int RTerm1, RTerm2, RTerm3, RTerm4;
    int gUIXPosition, gUIYPosition;
    
    // Declare variables that are adjustable in the EA properties inputs
    extern string MENUPAIRS         = "--- Choose menu pairs ---",
                  MenuPair1         = "EURUSD",
                  MenuPair2         = "USDCHF",
                  MenuPair3         = "GBPUSD",
                  MenuPair4         = "USDJPY";
    extern string MENUPERIODS       = "--- Choose menu periods ---";
    extern int    MenuPeriod1       = 1,     //1Min
                  MenuPeriod2       = 15,    //15Min
                  MenuPeriod3       = 60,    //1Hour
                  MenuPeriod4       = 1440;  //1Day                    
    extern string GUICOLORS         = "--- Color settings ---";
    extern color  ChartBtnColor     = Red,
                  ChartMenuColor    = OrangeRed,
                  ChartMenuColor2   = Orange,
                  TerminalBtnColor  = Blue,
                  TerminalMenuColor = RoyalBlue;
    extern string GUIOFFSET         = "--- Offset from borders ---";
    extern int    GUIXOffset        = -180,
                  GUIYOffset        = 30;
    
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());	
    	guiRemoveAll(hwnd);
    	
       // Measures chart width and height and sets default GUI X/Y-positions to top right of chart (with an offset)
       AutoPositionControlPanel();
    
    
       // Add interface with panel and buttons to chart function call
       BuildInterface();
    
       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);
       
       return(0);
      }
    
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {   
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
      }
    
    
    // MT4GUI functions to capture Menu & Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {		
    	// If menuTerminalBtn is clicked execute function OpenTerminalMenu()
    	if (guiIsClicked(hwnd,menuTerminalBtn)) TerminalMenu();
    
    	// If chartBtn is clicked execute function OpenTerminalMenu()
    	if (guiIsClicked(hwnd,menuChartBtn)) ChartMenu();
    	
    	//If Radio chart buttons is checked change chart
    	CheckRadioButton();
    }
    
    
    // MT4GUI functions to build Interface with labels, buttons & textfields
    //+-------------------------------------------------------------------------------------------+
    void BuildInterface()
    {
       // Build control panel (labels) and set look and feel for it
     	controlPanelHeader  = guiAdd(hwnd,"label",gUIXPosition,gUIYPosition,120,20,"    ControlPanel");				
                                         
       // Create control panel menu buttons, Terminal & Chart and set look and feel for them
    	menuTerminalBtn = guiAdd(hwnd,"button",gUIXPosition,gUIYPosition+20,60,20,""); 
    	guiSetBorderColor(hwnd,menuTerminalBtn,TerminalMenuColor);
    	guiSetBgColor(hwnd,menuTerminalBtn, TerminalBtnColor);
    	guiSetTextColor(hwnd,menuTerminalBtn,White);
    	guiSetText(hwnd,menuTerminalBtn,"Terminal",10,"Arial Bold");
    	
       menuChartBtn = guiAdd(hwnd,"button",gUIXPosition+60,gUIYPosition+20,60,20,""); 
    	guiSetBorderColor(hwnd,menuChartBtn,ChartMenuColor);
    	guiSetBgColor(hwnd,menuChartBtn,ChartBtnColor);
    	guiSetTextColor(hwnd,menuChartBtn,Black);
    	guiSetText(hwnd,menuChartBtn,"Chart",10,"Arial Bold");
    }
    
    
    // MT4GUI functions to change chart settings within GUI
    //+-------------------------------------------------------------------------------------------+
    void ChartMenu()
    {
       if (chartMenuOpen)
       {
       RemoveCPMC();
       }
       else
       {
          RemoveCPMT();
          controlPanelMenuChart  = guiAdd(hwnd,"label",gUIXPosition,gUIYPosition+40,120,80,"");
          guiSetBgColor(hwnd,controlPanelMenuChart,ChartMenuColor);
          chartMenuOpen=true;
          
    	   // Radio Buttons for chart functions
    	   RChart1    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+40,120,20,MenuPair1); 
    	   RChart2    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+60,120,20,MenuPair2); 
    	   RChart3    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+80,120,20,MenuPair3);
    	   RChart4    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+100,120,20,MenuPair4);
    
    	   RChart5    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+120,120,20,PeriodToText(MenuPeriod1)); 
    	   RChart6    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+140,120,20,PeriodToText(MenuPeriod2)); 
    	   RChart7    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+160,120,20,PeriodToText(MenuPeriod3));
    	   RChart8    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+180,120,20,PeriodToText(MenuPeriod4));	   
    	   
    	   // Look and feel for chart radio buttons
          guiSetBgColor(hwnd,RChart1,ChartMenuColor);guiSetBgColor(hwnd,RChart2,ChartMenuColor);guiSetBgColor(hwnd,RChart3,ChartMenuColor);guiSetBgColor(hwnd,RChart4,ChartMenuColor);
          guiSetBgColor(hwnd,RChart5,ChartMenuColor2);guiSetBgColor(hwnd,RChart6,ChartMenuColor2);guiSetBgColor(hwnd,RChart7,ChartMenuColor2);guiSetBgColor(hwnd,RChart8,ChartMenuColor2);
       }
    }
    
    
    // MT4GUI functions to change terminal actions within GUI
    //+-------------------------------------------------------------------------------------------+
    void TerminalMenu()
    {
       if (terminalMenuOpen)
       {
          RemoveCPMT();
       }
       else
       {
          RemoveCPMC();
          controlPanelMenuTerminal  = guiAdd(hwnd,"label",gUIXPosition,gUIYPosition+40,120,80,"");
          guiSetBgColor(hwnd,controlPanelMenuTerminal,TerminalMenuColor);
          terminalMenuOpen=true;
          
          // Radio Buttons for terminal functions
          RTerm1    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+40,120,20,"Min terminal"); 
    	   RTerm2    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+60,120,20,"Max terminal"); 
    	   RTerm3    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+80,120,20,"Close terminal");
    	   RTerm4    = guiAdd(hwnd,"radio",gUIXPosition,gUIYPosition+100,120,20,"Close chart");
          // Look and feel for terminal radio buttons
          guiSetBgColor(hwnd,RTerm1,TerminalMenuColor);guiSetBgColor(hwnd,RTerm2,TerminalMenuColor);guiSetBgColor(hwnd,RTerm3,TerminalMenuColor);guiSetBgColor(hwnd,RTerm4,TerminalMenuColor);}
    }
    
    
    // MT4GUI functions to remove controlPanelMenuTerminal
    //+-------------------------------------------------------------------------------------------+
    void RemoveCPMC()
    {
       guiRemove(hwnd,controlPanelMenuChart);
       guiRemove(hwnd,RChart1);guiRemove(hwnd,RChart2);guiRemove(hwnd,RChart3);guiRemove(hwnd,RChart4);
       guiRemove(hwnd,RChart5);guiRemove(hwnd,RChart6);guiRemove(hwnd,RChart7);guiRemove(hwnd,RChart8);
       chartMenuOpen=false;  
    }
    
    
    // MT4GUI functions to remove controlPanelMenuChart
    //+-------------------------------------------------------------------------------------------+
    void RemoveCPMT()
    {
       guiRemove(hwnd,controlPanelMenuTerminal);
       guiRemove(hwnd,RTerm1);guiRemove(hwnd,RTerm2);guiRemove(hwnd,RTerm3);guiRemove(hwnd,RTerm4);
       terminalMenuOpen=false; 
    }
    
    
    // MT4GUI functions check radio buttons and change chart pair/period or execute terminal function
    //+-------------------------------------------------------------------------------------------+
    void CheckRadioButton()
    {
       string tempdel = CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8)+CharToStr(8);
    	if (guiIsChecked(hwnd, RChart1) && Symbol()!=MenuPair1) {guiChangeSymbol(hwnd, tempdel+MenuPair1); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart2) && Symbol()!=MenuPair2) {guiChangeSymbol(hwnd, tempdel+MenuPair2); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart3) && Symbol()!=MenuPair3) {guiChangeSymbol(hwnd, tempdel+MenuPair3); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart4) && Symbol()!=MenuPair4) {guiChangeSymbol(hwnd, tempdel+MenuPair4); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart5) && Period()!=MenuPeriod1) {guiChangeSymbol(hwnd, tempdel+Symbol()+","+MenuPeriod1); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart6) && Period()!=MenuPeriod2) {guiChangeSymbol(hwnd, tempdel+Symbol()+","+MenuPeriod2); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart7) && Period()!=MenuPeriod3) {guiChangeSymbol(hwnd, tempdel+Symbol()+","+MenuPeriod3); RemoveCPMC();}
    	if (guiIsChecked(hwnd, RChart8) && Period()!=MenuPeriod4) {guiChangeSymbol(hwnd, tempdel+Symbol()+","+MenuPeriod4); RemoveCPMC();}	
    	
    	
       //If Radio terminal buttons is checked call terminal function
    	if (guiIsChecked(hwnd, RTerm1)) {guiMinimizeTerminal(); RemoveCPMT();}  //Minimize terminal
    	if (guiIsChecked(hwnd, RTerm2)) {guiMaximizeTerminal(); RemoveCPMT();}  //Maximize terminal
    	if (guiIsChecked(hwnd, RTerm3)) {guiCloseTerminal(); RemoveCPMT();}  //Close terminal
    	if (guiIsChecked(hwnd, RTerm4)) {guiCloseChart(hwnd); RemoveCPMT();}  //Close chart	
    }
    
    
    // MT4GUI Function for getting Chart Width and postition X/Y for ControlPanel (GUI)
    //+-------------------------------------------------------------------------------------------+
    void AutoPositionControlPanel()
    {
       gUIXPosition = guiGetChartWidth(hwnd)+GUIXOffset;
       gUIYPosition = GUIYOffset;
    }
    
    
    // MT4/MQL4 Function to convert period number to text string
    //+-------------------------------------------------------------------------------------------+
    string PeriodToText(int period)
    {
       switch (period)
       {
          case 1:
                return("M1");
                break;
          case 5:
                return("M5");
                break;
          case 15:
                return("M15");
                break;
          case 30:
                return("M30");
                break;
          case 60:
                return("H1");
                break;
          case 240:
                return("H4");
                break;
          case 1440:
                return("D1");
                break;
          case 10080:
                return("W1");
                break;
          case 43200:
                return("MN1");
                break;
       }
    }
    

    VIDEOCLIP:

    Thats all folks!

    Tomorrow I will show you several ways to use links in MT4, with MT4GUI.

  38. DAY3: Simple EA-login manager

    1 Comment

    DAY3: Simple EA Login Manager

    Introduction

    Welcome to Blog No 3 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

    DAY3: Objective

    Does your family & friends use your computer now and then?
    Afraid that they will start your EA without knowing how to handle it?
    Don’t be, with this piece of code you are the only one allowed to start it!

    DAY3: Functions covered

    MT4GUI

  39. MT4GUI labels (build a login panel with labels)
  40. MT4GUI textfield (to be able to manually type a username & password)
  41. MT4GUI button (Login, exit and move panel buttons on MT4 chart)
  42. MT4GUI terminal function (get chart width and height for default GUI positioning)
  43. Look and feel (Size, color, positioning etc of GUI objects)
  44. MT4 (MQL4) & Windows

  45. Windows dll call (used for exit EA from within code (advanced))
  46. Alert (pop-up box confirming user actions)
  47. CODEBASE:

    // mt4gui-SimpleEALogin.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com) 
    // Version 0.1, 20130403
    
    // Include library file with common functions for mt4gui
    #include <mt4gui.mqh>
    
    // Include library and import dll to be able to remove EA from chart automatically (advanced)
    #include <WinUser32.mqh>
    #import "user32.dll"
    int GetAncestor(int, int);
    #import
    
    // Declare global variables
    int hwnd = 0;
    int loginBtn, exitBtn;
    int moveUpBtn, moveRightBtn, moveDownBtn, moveLeftBtn;
    int loginHeader, loginPanel;
    int usernameTextField, passwordTextField;
    int gUIXPosition, gUIYPosition;
    int authenticationFail=0;
                  
    // User credentials (fill in the ones you want to use)
    string username = "Administrator",
           password = "Password";
    
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());	
    	guiRemoveAll(hwnd);	
    
       // Measures chart width and height and sets default GUI X/Y-positions to center of the chart
       gUIXPosition = guiGetChartWidth(hwnd)/2-90;
       gUIYPosition = guiGetChartHeight(hwnd)/2-85;
    
       // Add interface with panel and buttons to chart function call
       BuildInterface();
    
       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);
       
       return(0);
      }
    
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
      }
    
    
    // MT4GUI functions to capture Menu & Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {		
    	// If exitBtn is clicked execute function ExitEA()
    	if (guiIsClicked(hwnd,exitBtn)) ExitEA();
    
    	// If loginBtn is clicked execute function LoginEA()
    	if (guiIsClicked(hwnd,loginBtn)) LoginEA();
    	
    	// If moveBtns are clicked change the default X/Y coordinates accordingly (Remove all objects and rebuild interface)
    	if (guiIsClicked(hwnd,moveUpBtn)) {gUIYPosition = gUIYPosition-10; guiRemoveAll(hwnd); BuildInterface();}
       if (guiIsClicked(hwnd,moveRightBtn)) {gUIXPosition = gUIXPosition+10; guiRemoveAll(hwnd); BuildInterface();}
       if (guiIsClicked(hwnd,moveDownBtn)) {gUIYPosition = gUIYPosition+10; guiRemoveAll(hwnd); BuildInterface();}
       if (guiIsClicked(hwnd,moveLeftBtn)) {gUIXPosition = gUIXPosition-10; guiRemoveAll(hwnd); BuildInterface();}
    }
    
    
    // MT4GUI functions to build Interface with labels, buttons & textfields
    //+-------------------------------------------------------------------------------------------+
    void BuildInterface()
    {
       // Build Login panel (labels) and set look and feel for it
     	loginHeader  = guiAdd(hwnd,"label",gUIXPosition,gUIYPosition,180,20,"Please login:");  
    	loginPanel   = guiAdd(hwnd,"label",gUIXPosition,gUIYPosition+20,180,150,""); 	
    	guiSetBgColor(hwnd,loginHeader,DarkBlue);
    	guiSetTextColor(hwnd,loginHeader,White);
       guiSetBgColor(hwnd,loginPanel,DarkSlateGray);				
                                         
       // Create buttons, Login & exit and set look and feel for them
    	loginBtn = guiAdd(hwnd,"button",gUIXPosition+100,gUIYPosition+110,70,40,""); 
    	guiSetBorderColor(hwnd,loginBtn,RoyalBlue);
    	guiSetBgColor(hwnd,loginBtn, Blue);
    	guiSetTextColor(hwnd,loginBtn,White);
    	guiSetText(hwnd,loginBtn,"Login",25,"Arial Bold");
    	
       exitBtn = guiAdd(hwnd,"button",gUIXPosition+10,gUIYPosition+110,70,40,""); 
    	guiSetBorderColor(hwnd,exitBtn,OrangeRed);
    	guiSetBgColor(hwnd,exitBtn,Red);
    	guiSetTextColor(hwnd,exitBtn,Black);
    	guiSetText(hwnd,exitBtn,"Exit",25,"Arial Bold");
    
    
       // Create four arrow buttons, for move panel
       moveUpBtn = guiAdd(hwnd,"button",gUIXPosition+80,gUIYPosition-20,20,20,""); 
    	guiSetTextColor(hwnd,moveUpBtn,White);
       guiSetBorderColor(hwnd,moveUpBtn,Black);
    	guiSetBgColor(hwnd,moveUpBtn,Black);
    	guiSetText(hwnd,moveUpBtn,CharToStr(217),20,"Wingdings");
    
    	moveRightBtn = guiAdd(hwnd,"button",gUIXPosition+180,gUIYPosition+80,20,20,""); 
    	guiSetTextColor(hwnd,moveRightBtn,White);
       guiSetBorderColor(hwnd,moveRightBtn,Black);
    	guiSetBgColor(hwnd,moveRightBtn,Black);
    	guiSetText(hwnd,moveRightBtn,CharToStr(216),20,"Wingdings");
    	
    	moveDownBtn = guiAdd(hwnd,"button",gUIXPosition+80,gUIYPosition+170,20,20,""); 
    	guiSetTextColor(hwnd,moveDownBtn,White);
       guiSetBorderColor(hwnd,moveDownBtn,Black);
    	guiSetBgColor(hwnd,moveDownBtn,Black);
    	guiSetText(hwnd,moveDownBtn,CharToStr(218),20,"Wingdings");
    	
    	moveLeftBtn = guiAdd(hwnd,"button",gUIXPosition-20,gUIYPosition+80,20,20,""); 
    	guiSetTextColor(hwnd,moveLeftBtn,White);
       guiSetBorderColor(hwnd,moveLeftBtn,Black);
    	guiSetBgColor(hwnd,moveLeftBtn,Black);
    	guiSetText(hwnd,moveLeftBtn,CharToStr(215),20,"Wingdings");
    
    
    	//Add a username and password text field for manual input using user adjustable X/Y-position (size fixed to 150x20)
    	usernameTextField = guiAdd(hwnd,"text",gUIXPosition+10,gUIYPosition+40,160,20,"Username");	
       passwordTextField = guiAdd(hwnd,"text",gUIXPosition+10,gUIYPosition+70,160,20,"Password");
       guiSetTextColor(hwnd,usernameTextField,Gray);
       guiSetTextColor(hwnd,passwordTextField,Gray);
    }
    
    
    // Windows/MT4 function to exit EA (advanced)
    //+-------------------------------------------------------------------------------------------+
    void ExitEA()
    {
       Alert ("This exits your EA");
            int hWnd = WindowHandle(Symbol(), Period());
            #define MT4_WMCMD_REMOVE_EXPERT   33050 /* Remove expert advisor from chart */ 
            PostMessageA(hWnd, WM_COMMAND, MT4_WMCMD_REMOVE_EXPERT, 0);
    }
    
    
    // MT4GUI function check textfields (username & password), MT4 pop-up alerts
    //+-------------------------------------------------------------------------------------------+
    void LoginEA()
    {
       //Check that Username and password are correct
       if (guiGetText(hwnd,usernameTextField)==username && guiGetText(hwnd,passwordTextField)==password)
       {Alert ("Authorization successful (call your own function for continuation of EA execution)");guiRemoveAll(hwnd);authenticationFail=0;}
       else if (authenticationFail==0)
       {Alert ("Authorization failed, please try again (you have 2 of 2 retries left)"); authenticationFail++;}
       else if (authenticationFail==1)
       {Alert ("Authorization failed, please try again (you have 1 of 2 retries left)"); authenticationFail++;}
       else if (authenticationFail==2)
       {Alert ("Authentication failed 3 times, this blocks your login"); guiEnable (hwnd, loginBtn,0);}
    }
    

    VIDEOCLIP:

    Thats all folks!

    Tomorrow I will show you how you can use MT4-Terminal/chart functions with MT4GUI.

  48. DAY2: Preset Comments

    2 Comments

    DAY2: Preset Comments

    Introduction

    Welcome to Blog No 2 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

    DAY2: Objective

    Have you had trouble to follow up the results of your different trading strategies!?
    Don’t worry, today I will show you how you can add preset comments as well as manual ones to your trades.

    DAY2: Functions covered

    MT4GUI

  49. MT4 menu functions (Adding Options menu with submenu for enable/disable preset comment listbox and textfield on chart)
  50. MT4GUI listbox (6 preset list items + a manual one)
  51. MT4GUI textfield (to be able to manually type a trade comment)
  52. MT4GUI button (Execute trade button on MT4 chart)
  53. Look and feel (Size, color, positioning etc of GUI objects and menu)
  54. MT4 (MQL4)

  55. EA property inputs (set X/Y position of GUI and preset comments)
  56. Alert (pop-up box confirming user actions)
  57. CODEBASE:

    // mt4gui-PresetComments.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com)
    // Version 0.1, 20130402
    
    // Include library file with common functions for mt4gui
    #include
    
    // Declare global variables
    int hwnd = 0;
    int executeTradeBtn;
    int menuOptions,menuSubComments;
    int presetCommentList, presetCommentTextfield;
    
    //Default position of buttons (adjustable in the experts properties/inputs)
    extern int    GUIXPosition   = 10,
                  GUIYPosition   = 60;
    
    // Default 6 x PresetComments (adjustable in the experts properties/inputs)
    extern string PresetComment1 = "ManualStrategy1",
                  PresetComment2 = "ManualStrategy2",
                  PresetComment3 = "ManualStrategy3",
                  PresetComment4 = "AutotradeStrategy1",
                  PresetComment5 = "AutotradeStrategy2",
                  PresetComment6 = "AutotradeStrategy3",
                  ManualComment  = "";
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());
    	guiRemoveAll(hwnd);
    
    	// Add execute trade button to chart function call
       CreateExecuteTradeBtn();
    
       // Add options menu to MT4 function call
       CreateOptionsMenu();
    
       // Add interface with listbox and text field to chart function call
       BuildInterface();
    
       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);
    
       return(0);
      }
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
    
       //Check if something new has been typed into the manual comment text field and replace the list of comments if it is
       if (guiGetText(hwnd,presetCommentTextfield)!=ManualComment)
       {
       ManualComment = guiGetText(hwnd,presetCommentTextfield);
    
       //Removes the list to be able to rebuilt it with new manual comment (function BuildInterface())
       guiRemoveListAll(hwnd,presetCommentList);
       BuildInterface();
       }
      }
    
    // MT4GUI functions to create Menu
    //+-------------------------------------------------------------------------------------------+
    void CreateOptionsMenu()
    {
       // Add "Options" menu to MT4 menu
    	menuOptions = guiAddMenu(hwnd,"Options",0,0);
    
    	// Add sub-menu PresetComments with enable/disable
    	menuSubComments = guiAddMenu(hwnd,"PresetComments",menuOptions,1);
    
    	// Set Options menu background color to Blue
    	guiSetMenuBgColor(hwnd,menuOptions,Blue);
    
       // Set sub-menu Comments background color to Aqua and text to Black
    	guiSetMenuBgColor(hwnd,menuSubComments,Aqua);
    	guiSetMenuTextColor(hwnd,menuSubComments,Black);
    
    	// Set Comment menu item to enable
    	guiCheckMenu(hwnd,menuSubComments,true);
    }
    
    // MT4GUI functions to capture Menu & Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {
    	// If executeTradeBtn is clicked execute function ExecuteTrade()
    	if (guiIsClicked(hwnd,executeTradeBtn)) ExecuteTrade();
    
       // If menuitem SubComments is clicked check status, remove/create Screenshot button
       if (guiIsMenuClicked(hwnd,menuSubComments))
       {
          if (!guiIsMenuChecked(hwnd,menuSubComments))
          {
          guiRemove(hwnd,presetCommentList);
          guiRemove(hwnd,presetCommentTextfield);
          }
          else
          {
          presetCommentList=0;
          presetCommentTextfield=0;
          BuildInterface();
          }
       }
    }
    
    // MT4GUI functions to capture build Interface with textfield and list box
    //+-------------------------------------------------------------------------------------------+
    void BuildInterface()
    {
    	// Textfield Object
       if (presetCommentTextfield==0)
       {
       //Add a comment text field for manual input using user adjustable X/Y-position (size fixed to 150x20)
    	presetCommentTextfield = guiAdd(hwnd,"text",GUIXPosition,GUIYPosition+30,150,20,ManualComment);
    
    	//Set background and text color for comment text field
    	guiSetBgColor(hwnd,presetCommentTextfield,Yellow);guiSetTextColor(hwnd,presetCommentTextfield,Black);
    	}
    
    	// List box	with all the PresetComments listed. Position based on user adjustable X/Y-position, size fixed.
    	if (presetCommentList==0) presetCommentList = guiAdd(hwnd,"list",GUIXPosition,GUIYPosition,150,300,"PresetComments");
        guiAddListItem(hwnd,presetCommentList,PresetComment1);
    	guiAddListItem(hwnd,presetCommentList,PresetComment2);
    	guiAddListItem(hwnd,presetCommentList,PresetComment3);
    	guiAddListItem(hwnd,presetCommentList,PresetComment4);
    	guiAddListItem(hwnd,presetCommentList,PresetComment5);
    	guiAddListItem(hwnd,presetCommentList,PresetComment6);
    	guiAddListItem(hwnd,presetCommentList,ManualComment);
    
    	//Sets the first (0) list item to default
    	guiSetListSel(hwnd,presetCommentList,0);
    }
    
    // MT4GUI functions to create Button
    //+-------------------------------------------------------------------------------------------+
    void CreateExecuteTradeBtn()
    {
    	// Position and size of the button ,x ,y ,a ,b (x, y = position from top left corner. a, b = size of button)
    	executeTradeBtn = guiAdd(hwnd,"button",GUIXPosition+160,GUIYPosition,70,50,"");
    
    	// Execute trade button Border color
    	guiSetBorderColor(hwnd,executeTradeBtn,White);
    
    	// Execute trade button Background color
    	guiSetBgColor(hwnd,executeTradeBtn, Blue);
    
    	// Execute trade button Text color
    	guiSetTextColor(hwnd,executeTradeBtn,White);
    
    	// Add text to execute trade button
    	guiSetText(hwnd,executeTradeBtn,"Exec",25,"Arial Bold");
    }
    
    // MT4 function to execute a trade (only simulation, replace with your own execution code)
    //+-------------------------------------------------------------------------------------------+
    void ExecuteTrade()
    {
       Alert ("This could have executed a trade with comment: ", IndexToComment());
    }
    
    // Function to convert presetCommentList index number to corresponding Comment
    //+-------------------------------------------------------------------------------------------+
    string IndexToComment()
    {
       //Gets the selected list item index (0-6) and converts it to corresponding preset comment
       switch (guiGetListSel (hwnd, presetCommentList))
       {
          case 0:
                return(PresetComment1);
                break;
          case 1:
                return(PresetComment2);
                break;
          case 2:
                return(PresetComment3);
                break;
          case 3:
                return(PresetComment4);
                break;
          case 4:
                return(PresetComment5);
                break;
          case 5:
                return(PresetComment6);
                break;
          case 6:
                return(ManualComment);
                break;
       }
    }
    

    VIDEOCLIP:

    Thats all folks!

    Tomorrow I will show you how you can add “login functionality (user/pass)” with MT4GUI.

  58. DAY1: Screenshot Manager

    Leave a Comment

    DAY1: Screenshot Manager

    Introduction

    I had been developing indicators and EAs in MT4 MQL4 for about a year when I first came in touch with MT4GUI@FX1.
    It was a “magical” moment, it was like finding something completely unique that the developers of MT4 “forgotten” to implement.
    The functionality is amazing and the coding of it is rather easy, hey I can do it :-).

    I will, in a miniseries of 10 blogs exploit MT4GUIs functionalities, with a daily blog update with new code example/functions.

    I hope you find it interesting as well as valuable!

    Sincerely

    Thommy Tikka

    DAY1: Objective

    Who hasn’t been frustrated by the lack of an easy way to within MT4 take screenshots of the charts for POST-trade analysis!?
    Now you can do it, and I will show you how!

    DAY1: Functions covered

    MT4GUI

  59. MT4 menu functions (Adding Options menu with submenus for enable/disable Screenshot button on chart and to set the screenshot size parameters)
  60. MT4GUI button (Actual screen shot button on MT4 chart)
  61. Look and feel (Size, color, rounded corners etc on menus and GUI object)
  62. MT4 (MQL4)

  63. WindowScreenShot (you will find your screenshots in the /MT4/Experts/Files/… directory)
  64. Alert (pop-up box confirming user actions)
  65. CODEBASE:

    	
    // mt4gui-Screenshot.mq4
    // Created by Thommy Tikka (thommy_tikka@hotmail.com) 
    // Version 0.1, 20130401
    
    // Include library file with common functions for mt4gui
    #include <mt4gui.mqh>
    
    // Declare global variables
    int hwnd = 0;
    int screenshotBtn;
    int menuOptions,menuSubScreenshot, menuSubResolution, menuSubSub640, menuSubSub1024, menuSubSub1280;
    
    // Default Screenshot resolution set to 1024x768
    int screenShotResX=1024, screenShotResY=768; 
    
    
    // MT4 function called during the module initialization
    //+-------------------------------------------------------------------------------------------+
    int init()
      {
    	hwnd = WindowHandle(Symbol(),Period());	
    	guiRemoveAll(hwnd);	
    
       // Add screenshot button to chart function call
       CreateScreenshotBtn();
       
       // Add options menu to MT4 function call
       CreateOptionsMenu();
    
       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);
       
       return(0);
      }
    
    // MT4 function called on every MT4 tick
    //+-------------------------------------------------------------------------------------------+
    int start()
      {
       // Call function ManageEvents on every MT4 tick
       ManageEvents();
      }
    
    
    // MT4GUI functions to create Button
    //+-------------------------------------------------------------------------------------------+
    void CreateScreenshotBtn()
    {
    	// Position and size of the button ,x ,y ,a ,b (x, y = position from top left corner. a, b = size of button)
    	screenshotBtn = guiAdd(hwnd,"button",10,30,30,20,"");
    	
    	// Screenshot button rounded corners radius
    	guiSetBorderRadius(hwnd,screenshotBtn, 10); 
    	
    	// Screenshot button Border color
    	guiSetBorderColor(hwnd,screenshotBtn,White); 
    	
    	// Screenshot button Background color
    	guiSetBgColor(hwnd,screenshotBtn, Blue); 
    	
    	// Screenshot button Text color
    	guiSetTextColor(hwnd,screenshotBtn,White);
    	
    	// Add "eye" webdings symbol to screenshot button
    	guiSetText(hwnd,screenshotBtn,"N",25,"Webdings");
    }
    
    
    // MT4GUI functions to create Menu
    //+-------------------------------------------------------------------------------------------+
    void CreateOptionsMenu()
    {	
       // Add "Options" menu to MT4 menu 
    	menuOptions = guiAddMenu(hwnd,"Options",0,0);
    	
    	// Add sub-menu Screenshot with enable/disable & sub-meny Resolution
    	menuSubScreenshot = guiAddMenu(hwnd,"ScreenShotBtn",menuOptions,1);
    	menuSubResolution = guiAddMenu(hwnd,"Resolution",menuOptions,0);
    
    	// Add sub-sub menu to Resolution menu
    	menuSubSub640 = guiAddMenu(hwnd,"Screen: 640x480",menuSubResolution,0);
    	menuSubSub1024 = guiAddMenu(hwnd,"Screen: 1024x768",menuSubResolution,0);
    	menuSubSub1280 = guiAddMenu(hwnd,"Sreen: 1280x1024",menuSubResolution,0);
    	
    	// Set Options menu background color to Aqua
    	guiSetMenuBgColor(hwnd,menuOptions,Aqua);
    	
       // Set sub-menu Screenshot background color to Blue and text to White
    	guiSetMenuBgColor(hwnd,menuSubScreenshot,Blue);
    	guiSetMenuTextColor(hwnd,menuSubScreenshot,White);
    	
    	// Set Screenshot meny item to enable
    	guiCheckMenu(hwnd,menuSubScreenshot,true);
    }
    
    
    // MT4GUI functions to capture Menu & Button Events
    //+-------------------------------------------------------------------------------------------+
    void ManageEvents()
    {		
    	// If screenshotBtn is clicked execute function ScreenShotMT4
    	if (guiIsClicked(hwnd,screenshotBtn)) ScreenShotMT4();
    
       // If menuitem SubScreenshot is clicked check status, remove/create Screenshot button
       if (guiIsMenuClicked(hwnd,menuSubScreenshot)) 
       {
          if (!guiIsMenuChecked(hwnd,menuSubScreenshot))
          {
          guiRemove(hwnd,screenshotBtn);
          }
          else
          {
          CreateScreenshotBtn();
          }
       }
       // If menuitem SubResolution is clicked and a sub-sub menu resolution is choosed that one will be used for the screen shot (including Alert pop-up)
       if (guiIsMenuClicked(hwnd,menuSubSub640)) {screenShotResX=640; screenShotResY=480; Alert ("Screenshot resolution set to: 640x480");}
       if (guiIsMenuClicked(hwnd,menuSubSub1024)) {screenShotResX=1024; screenShotResY=768;Alert ("Screenshot resolution set to: 1024x768");}
       if (guiIsMenuClicked(hwnd,menuSubSub1280)) {screenShotResX=1280; screenShotResY=1024;Alert ("Screenshot resolution set to: 1280x1024");}
    }
    
    // MT4 function for screen shot to file (...\'MT4-directory'\experts\files\...)
    //+-------------------------------------------------------------------------------------------+
    void ScreenShotMT4()
    {
       // Take screenshot based on pre-defined settings
       WindowScreenShot ("Button_"+Symbol()+"_M"+Period()+"_"+TimeToStr(TimeCurrent(),TIME_DATE)+"_"+Hour()+"."+Minute()+"."+Seconds()+".gif",screenShotResX,screenShotResX);
       
       // Alert user with a pop-up window
       Alert ("Screenshot taken (",screenShotResX,"x",screenShotResY,")");
    }
    

    VIDEOCLIP:

    Thats all folks!

    Tomorrow I will show you how you can use preset trade comments in your trading.

  66. Simple Trade Manager

    Leave a Comment

    Simple Trade Manager

    Objective

    Lets start coding a simple Trade Manager together. It shall display all open positions on chart and allow you to close them with 1 simple click. Lets develop this as an EA because EAs are designed to manage with Trades.

    Lets Start

    Lets create a new Expert Advisor template and start with following simple code:

    int init()
    {
    	ObjectsDeleteAll();
    	hwnd = WindowHandle(Symbol(),Period());		
    	// Lets remove all Objects from Chart before we start
    	guiRemoveAll(hwnd);
      return(0);
    }
    

    This is kind of classic start.

    Lets Build the Interface

    We will use button objects for this very simple Trade Manager EA. Of course we must generate the buttons dynamically based on Trades activate. Its good to make Button Width and Height configurable thats why we should define global variables like:

    // GUI Object Handles
    // Settings
    int GUIX = 50;
    int GUIY = 100;
    int ButtonWidth = 200;
    int ButtonHeight = 25;
    int ButtonDistance = 5;
    // Array Buffer to store buttons
    int Buttons[100]; // Lets support maximum 100 trades
    int Orders[100];	// Lets store Ticker IDs in this array
    

    These button configuration parameters can be made external or kept global internal, you can define this yourself. As you see we want to support maximum 100 buttons at once. Buttons[] Array will be used to store button gui handles and Orders[] Array will be used to store the Order Ticked corresponding to index.


    In BuildInterface() function we enumarate all available trades, filter only BUY & SELL ones (Market Trades) which belongs to current Symbol and draw the buttons on Chart programatically. As you see we save the button gui Handles inside Button[] Array and Order Ticket inside Orders[] Array. We will need them later!


    Its also important to colorize buttons depending on direction of trade, BUY or SELL.

    void BuildInterface()
    {	
    	// Lets remove everything before redrawing
    	guiRemoveAll(hwnd);
    	ArrayInitialize(Buttons,0);
    	int x=GUIX,y=GUIY,idx=0;
    	// Lets Enumerate all open trades
    	for(int i=0;i<OrdersTotal();i++)
    			{
    				if (OrderSelect(i,SELECT_BY_POS))				
    				if (OrderSymbol()==Symbol())
    				if (idx<100)
    				if (OrderType()==OP_BUY || OrderType()==OP_SELL)
    				      {
    				        // Create a button
    					Buttons[idx]=guiAdd(hwnd,"button",x,y,ButtonWidth,ButtonHeight
    					,"Close #"+OrderTicket()+" x "+DoubleToStr(OrderLots(),2));
    
    					// Lets remember OrderID by Index													
    					Orders[idx]=OrderTicket();
    
    					// Colorize the buttons based on LONG or SHORT Position
    					if (OrderType()==OP_BUY) guiSetBgColor(hwnd,Buttons[idx],Lime); else guiSetBgColor(hwnd,Buttons[idx],Tomato); 						
    						
    					// Lets move the x,y to keep the interface moving
    					y+=ButtonHeight+ButtonDistance;						
    					idx++;
    				      }
    			}
    }
    

    As you see in code we do also play a sound by closing the trades.

    Detect new/closed trades

    Of course our code must detect new trades automatically. Here is a simple way todo this: of course this is not 100% secure way but it works for our basic case.

    // Lets detect Change in Orders and rebuild interface
    if (LastKnownOrdersCount!=OrdersTotal()) 
           { 
    	BuildInterface(); 
    	LastKnownOrdersCount=OrdersTotal(); 
    	}
    

    As you see in code we compare Last Known amount of OrdersTotal() and current OrdersTotal(), if there is a discrepancy we assume there is some change in Orders and Rebuild the Interface and save current OrdersTotal state in our global variable LastKnownOrdersCount.

    Our Cleanup

    There is not much to say about this part:

    int deinit()
      {
       // Very important to cleanup and remove all gui items from chart      
       if (hwnd>0) { guiRemoveAll(hwnd);   	guiCleanup(hwnd ); }
       return(0);
      }
    

    Finally

    Now we have all parts together. See it in action:

    Download

    Please use Downloads Area to Download all parts, search for mt4gui-SimpleTM.mq4