Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2016.10.27 12:53
Libraries

The MasterWindows Library - library for MetaTrader 4

| English Español Português 日本語 Deutsch Русский

Views:
519
Rating:
votes: 9
\MQL4\Include\
ClassUnit.mqh (15.5 KB)view
ClassRow.mqh (22.28 KB)view
ClassWin.mqh (8.23 KB)view
\MQL4\Experts\
test1.mq4 (7.93 KB)view

The "MQL5 for "Dummies": How to Design and Construct Object Classes" articles describes how you can create a user-friendly interface for your programs. Implementation of interactive windows is based on the use of the MasterWindows class library.

Fig. 1. Example of the MasterWindows library use

Fig. 1. Example of the MasterWindows library use

The MasterWindows library consists of three base classes:

  • the base CCell class:
    //+------------------------------------------------------------------+
    //| The base CELL class CCell                                        |
    //+------------------------------------------------------------------+
    class CCell
      {
    private:
    protected:
       bool              on_event;      // Event handling flag
       ENUM_OBJECT       type;          // Cell type
    public:
       WinCell           Property;      // Cell properties
       string            name;          // Cell name
       //+---------------------------------------------------------------+
       // Class constructor
       void              CCell();
       virtual     // Method: draw an object
       void              Draw(string m_name,
                              int m_xdelta,
                              int m_ydelta,
                              int m_bsize);
       virtual     // The OnChartEvent event handling method
       void              OnEvent(const int id,
                                 const long &lparam,
                                 const double &dparam,
                                 const string &sparam);
      };
    
  • the base CRow class, consists of cells of the CCell class:
    //+------------------------------------------------------------------+
    //| The base ROW class CRow                                          |
    //+------------------------------------------------------------------+
    class CRow
      {
    protected:
       bool              on_event;      // Event handling flag
    public:
       string            name;          // Row name
       WinCell           Property;      // Row properties
       //+---------------------------------------------------------------+
       // Class constructor
       void              CRow();
       virtual     // Method: draw a row
       void              Draw(string m_name,
                              int m_xdelta,
                              int m_ydelta,
                              int m_bsize);
       virtual     // The OnChartEvent event handling method
       void              OnEvent(const int id,
                                 const long &lparam,
                                 const double &dparam,
                                 const string &sparam);
      };
    
  • the base CWin class, consists of rows of the CRow class:
    //+------------------------------------------------------------------+
    //| The base Window class CWin                                       |
    //+------------------------------------------------------------------+
    class CWin
      {
    private:
       void              SetXY(int m_corner);// The method for calculating coordinates
    protected:
       bool              on_event;   // Event handling flag
    public:
       string            name;       // Window name
       int               w_corner;   // Anchor corner
       int               w_xdelta;   // Vertical indent
       int               w_ydelta;   // Horizontal indent
       int               w_xpos;     // The X coordinate of the anchor point
       int               w_ypos;     // The Y coordinate of the anchor point
       int               w_bsize;    // The width of the window
       int               w_hsize;    // The height of the window
       int               w_h_corner; // The anchor corner of the HIDE mode
       WinCell           Property;   // Window properties
       u//---
       CRowType1         STR1;       // Declaring the class row
       CRowType2         STR2;       // Declaring the class row
       CRowType3         STR3;       // Declaring the class row
       CRowType4         STR4;       // Declaring the class row
       CRowType5         STR5;       // Declaring the class row
       CRowType6         STR6;       // Declaring the class row
       //+---------------------------------------------------------------+
       // Class constructor
       void              CWin();
       // Data obtaining method
       void              SetWin(string m_name,
                                int m_xdelta,
                                int m_ydelta,
                                int m_bsize,
                                int m_corner);
       virtual     // Method: draw a window
       void              Draw(int &MMint[][3],
                              string &MMstr[][3],
                              int count);
       virtual     // The OnEventTick event processing method
       void              OnEventTick();
       virtual     // The OnChartEvent event handling method
       void              OnEvent(const int id,
                                 const long &lparam,
                                 const double &dparam,
                                 const string &sparam);
      };
    

and 10 descendants.

The attachment contains template and code sample where the MasterWindows library is used. The code has been generated using the visual window constructor MasterWindows for MQL5. Test program is a model, i.e. it has no functionality (except for close window function).

You can use any number and combination of rows in a window. The figure shows the basic versions of rows and the window header:

Fig. 2. Basic options and possibilities of the library

Fig. 2. Basic options and possibilities of the library

For example, for the "Testing Performance of Moving Averages Calculation in MQL5" article, we have created the following interface using the proposed library.

Fig. 3. An example of using the MasterWindows library

Fig. 3. An example of using the MasterWindows library

Gallery:

Fig. 4. An example of using the library in trade panel

Fig. 4. An example of using the library in trade panel

Fig. 5. An example of using the library in a game panel

Fig. 5. An example of using the library in a game panel

Fig. 6. An example of using the library in trade panel

Fig. 6. An example of using the library in trade panel

Fig. 7. An example of using the library in multi-currency trade panel

Fig. 7. An example of using the library in multi-currency trade panel

Recommendations:

  • For a better display of created interface windows, use graphical schemes with a black background.

Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/15883

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

Holt's double exponential smoothing trend Holt's double exponential smoothing trend

Holt's double exponential smoothing - the trend component (mt4 version).

Holt's double exponential smoothing (mt4 version) Holt's double exponential smoothing (mt4 version)

Holt's double exponential smoothing with linear forecasting.