//+------------------------------------------------------------------+ //| Control panel MCM.mq5 | //| Copyright 2010, Lizar | //| https://login.mql5.com/ru/users/Lizar | //| Revision 2010.12.09 | //+------------------------------------------------------------------+ enum ENUM_CHART_EVENT_SYMBOL { CHARTEVENT_NEWBAR_NO =0, // No events CHARTEVENT_NEWBAR_M1 =0x00000001, // "New bar" event on M1 chart CHARTEVENT_NEWBAR_M2 =0x00000002, // "New bar" event on M2 chart CHARTEVENT_NEWBAR_M3 =0x00000004, // "New bar" event on M3 chart CHARTEVENT_NEWBAR_M4 =0x00000008, // "New bar" event on M4 chart CHARTEVENT_NEWBAR_M5 =0x00000010, // "New bar" event on M5 chart CHARTEVENT_NEWBAR_M6 =0x00000020, // "New bar" event on M6 chart CHARTEVENT_NEWBAR_M10=0x00000040, // "New bar" event on M10 chart CHARTEVENT_NEWBAR_M12=0x00000080, // "New bar" event on M12 chart CHARTEVENT_NEWBAR_M15=0x00000100, // "New bar" event on M15 chart CHARTEVENT_NEWBAR_M20=0x00000200, // "New bar" event on M20 chart CHARTEVENT_NEWBAR_M30=0x00000400, // "New bar" event on M30 chart CHARTEVENT_NEWBAR_H1 =0x00000800, // "New bar" event on H1 chart CHARTEVENT_NEWBAR_H2 =0x00001000, // "New bar" event on H2 chart CHARTEVENT_NEWBAR_H3 =0x00002000, // "New bar" event on H3 chart CHARTEVENT_NEWBAR_H4 =0x00004000, // "New bar" event on H4 chart CHARTEVENT_NEWBAR_H6 =0x00008000, // "New bar" event on H6 chart CHARTEVENT_NEWBAR_H8 =0x00010000, // "New bar" event on H8 chart CHARTEVENT_NEWBAR_H12=0x00020000, // "New bar" event on H12 chart CHARTEVENT_NEWBAR_D1 =0x00040000, // "New bar" event on D1 chart CHARTEVENT_NEWBAR_W1 =0x00080000, // "New bar" event on W1 chart CHARTEVENT_NEWBAR_MN1=0x00100000, // "New bar" event on MN chart CHARTEVENT_TICK =0x00200000, // "New tick" event CHARTEVENT_ALL =0xFFFFFFFF, // All events }; string EventDescription(long event) { ENUM_CHART_EVENT_SYMBOL event_current=(ENUM_CHART_EVENT_SYMBOL)event; switch(event_current) { case CHARTEVENT_NEWBAR_NO: return(" Initialization "); // Initialization case CHARTEVENT_NEWBAR_M1: return(" M1 "); // "New bar" event on M1 chart case CHARTEVENT_NEWBAR_M2: return(" M2 "); // "New bar" event on M2 chart case CHARTEVENT_NEWBAR_M3: return(" M3 "); // "New bar" event on M3 chart case CHARTEVENT_NEWBAR_M4: return(" M4 "); // "New bar" event on M4 chart case CHARTEVENT_NEWBAR_M5: return(" M5 "); // "New bar" event on M5 chart case CHARTEVENT_NEWBAR_M6: return(" M6 "); // "New bar" event on M6 chart case CHARTEVENT_NEWBAR_M10:return(" M10 "); // "New bar" event on M10 chart case CHARTEVENT_NEWBAR_M12:return(" M12 "); // "New bar" event on M12 chart case CHARTEVENT_NEWBAR_M15:return(" M15 "); // "New bar" event on M15 chart case CHARTEVENT_NEWBAR_M20:return(" M20 "); // "New bar" event on M20 chart case CHARTEVENT_NEWBAR_M30:return(" M30 "); // "New bar" event on M30 chart case CHARTEVENT_NEWBAR_H1: return(" H1 "); // "New bar" event on H1 chart case CHARTEVENT_NEWBAR_H2: return(" H2 "); // "New bar" event on H2 chart case CHARTEVENT_NEWBAR_H3: return(" H3 "); // "New bar" event on H3 chart case CHARTEVENT_NEWBAR_H4: return(" H4 "); // "New bar" event on H4 chart case CHARTEVENT_NEWBAR_H6: return(" H6 "); // "New bar" event on H6 chart case CHARTEVENT_NEWBAR_H8: return(" H8 "); // "New bar" event on H8 chart case CHARTEVENT_NEWBAR_H12:return(" H12 "); // "New bar" event on H12 chart case CHARTEVENT_NEWBAR_D1: return(" D1 "); // "New bar" event on D1 chart case CHARTEVENT_NEWBAR_W1: return(" W1 "); // "New bar" event on W1 chart case CHARTEVENT_NEWBAR_MN1:return(" MN1 "); // "New bar" event on MN chart case CHARTEVENT_TICK :return(" tick "); // "New tick" event default: return(" Unknown event "); } return(" Unknown event "); } ENUM_TIMEFRAMES EventToPeriod(long event) { ENUM_CHART_EVENT_SYMBOL event_current=(ENUM_CHART_EVENT_SYMBOL)event; switch(event_current) { case CHARTEVENT_NEWBAR_M1: return(PERIOD_M1); case CHARTEVENT_NEWBAR_M2: return(PERIOD_M2); case CHARTEVENT_NEWBAR_M3: return(PERIOD_M3); case CHARTEVENT_NEWBAR_M4: return(PERIOD_M4); case CHARTEVENT_NEWBAR_M5: return(PERIOD_M5); case CHARTEVENT_NEWBAR_M6: return(PERIOD_M6); case CHARTEVENT_NEWBAR_M10:return(PERIOD_M10); case CHARTEVENT_NEWBAR_M12:return(PERIOD_M12); case CHARTEVENT_NEWBAR_M15:return(PERIOD_M15); case CHARTEVENT_NEWBAR_M20:return(PERIOD_M20); case CHARTEVENT_NEWBAR_M30:return(PERIOD_M30); case CHARTEVENT_NEWBAR_H1: return(PERIOD_H1); case CHARTEVENT_NEWBAR_H2: return(PERIOD_H2); case CHARTEVENT_NEWBAR_H3: return(PERIOD_H3); case CHARTEVENT_NEWBAR_H4: return(PERIOD_H4); case CHARTEVENT_NEWBAR_H6: return(PERIOD_H6); case CHARTEVENT_NEWBAR_H8: return(PERIOD_H8); case CHARTEVENT_NEWBAR_H12:return(PERIOD_H12); case CHARTEVENT_NEWBAR_D1: return(PERIOD_D1); case CHARTEVENT_NEWBAR_W1: return(PERIOD_W1); case CHARTEVENT_NEWBAR_MN1:return(PERIOD_MN1); default: return(PERIOD_CURRENT); } return(PERIOD_CURRENT); } #define MSG_CONTROL_PANEL_MCM "MCM Control panel for multicurrency mode " #define MSG_EVENT "Waiting for event... " #define MSG_SELECT_SYMBOL "Select symbols for multicurrency mode " #define MSG_SYMBOL_CHANGE "The number of symbols in Market Watch has changed " #define MSG_HELP "Help - brief information about program " #define MSG_SYMBOL_PERIOD "Set symbol and period for the currenct chart " #define MSG_ESTABLISH_EVENTS "Set event for selected symbol " #include //+------------------------------------------------------------------+ //| Class CControlElement. | //| Purpose: A set of functions for menu | //+------------------------------------------------------------------+ class CControlElement : public CChartObjectButton { protected: //--- int m_intparam; uint m_uintparam; //--- //--- Button parameters: ENUM_BASE_CORNER m_corner; // corner int m_coord_x; // X coordinate int m_coord_y; // Y coordinate //--- //--- Control panel parameters: string m_description; // description int m_size_x; // X size int m_size_y; // Y size int m_state; // status int m_state_select; // is selected int m_flag_visibility; color m_col_bg; // background color color m_col_font; // text color color m_col_select; string m_font; // font name int m_size_font; // font size ENUM_OBJECT m_type; // object type //--- public: void CControlElement(); bool CreateElement( ENUM_OBJECT type, // object type string name, // object name (button name) string description, // description or button text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color color col_select, string font="Segoe UI Semibold", // font name int size_font=8, // font size int state=0, // button status long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // chart binding corner ); bool DisplayElement(); bool Display(int coord_x, int coord_y, int size_x, int size_y); bool CreateButton( // Creates a button string name, // Button name string description, // Description or button text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=8, // font size int state=0, // button status long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ); bool DisplayButton(); // Show button bool CreateEdit( // Creates an Edit string name, // name string text, // text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=8, // font size long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ); bool DisplayBackground();// Show background on the chart bool CreateLabel( // Creates a Label string name, // object name (text label) int coord_x, // X coordinate int coord_y, // Y coordinate color col_font, // font color string font="Segoe UI Semibold", // font name int size_font=8, // font size long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding color ); bool DisplayLabel(); // Show label int Type() const { return(m_type); } bool Hide(); // Hide object bool Coord_x(int coord_x); int Coord_x() {return(m_coord_x);} bool Coord_y(int coord_y); int Coord_y() {return(m_coord_y);} bool Descript(string description); void StateElement(bool state) {m_state=state;} void ColorElement(color col_font) {m_col_font=col_font; Color(col_font);} bool StateElement() { return(m_state);} void FlagVisibility(int flag) {m_flag_visibility=flag;} int FlagVisibility() {return(m_flag_visibility);} void ChangeStateSelect() {m_state_select=m_state;} void ChangeState() {m_state=m_state_select;} void IntParam(int param) {m_intparam=param;} int IntParam() {return(m_intparam);} void UIntParam(int param) {m_uintparam=param;} int UIntParam() {return(m_uintparam);} }; void CControlElement :: CControlElement() { m_intparam=-1; m_uintparam=0; //--- Chart paramters: m_corner =CORNER_LEFT_LOWER; // binding corner m_chart_id =ChartID(); // chart ID m_window =0; // chart window m_num_points=1; // number of anchor points of object //--- Control element parameters: m_state=false; // status m_col_bg=(color)ChartGetInteger(m_chart_id,CHART_COLOR_BACKGROUND); m_col_font=(color)ChartGetInteger(m_chart_id,CHART_COLOR_FOREGROUND); m_flag_visibility=OBJ_ALL_PERIODS; m_font="Segoe UI Semibold"; // font name m_size_font=10; // font size //--- } bool CControlElement :: Descript(string description) { m_description=description; if(!Description(description)) return(false); return(true); } bool CControlElement :: Coord_x(int coord_x) { m_coord_x=coord_x; if(!X_Distance(coord_x)) return(false); return(true); } bool CControlElement :: Coord_y(int coord_y) { m_coord_y=coord_y; if(!Y_Distance(coord_y)) return(false); return(true); } //+------------------------------------------------------------------+ //| Show control element | //| INPUT: no. | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: DisplayButton() { if(!Create(m_chart_id,m_name,m_window,m_coord_x,m_coord_y,m_size_x,m_size_y)) return(false); // Create button if(!Description(m_description)) return(false); // description or button text if(!BackColor (m_col_bg)) return(false); // background color if(!Font(m_font)) return(false); // font name if(!FontSize(m_size_font)) return(false); // font size if(!Color(m_col_font)) return(false); // text color if(!State(m_state)) return(false); // state if(!Corner(m_corner)) return(false); // binding corner return(true); } bool CControlElement :: DisplayElement() { if(!Create(m_chart_id,m_name,m_window,m_coord_x,m_coord_y,m_size_x,m_size_y)) return(false); // Create element if(!Description(m_description)) return(false); // description of text if(!BackColor (m_col_bg)) return(false); // background color if(!Font(m_font)) return(false); // font name if(!FontSize(m_size_font)) return(false); // font size if(m_state) { if(!Color(m_col_select)) return(false); }// selected text color else { if(!Color(m_col_font)) return(false); }// text color if(!State(m_state)) return(false); // state if(!Corner(m_corner)) return(false); // binding corner if(!SetInteger(OBJPROP_READONLY,true)) return(false); if(!Timeframes(m_flag_visibility)) return(false); return(true); } bool CControlElement :: Display(int coord_x, int coord_y, int size_x, int size_y) { m_coord_x=coord_x; m_coord_y=coord_y; m_size_x=size_x; m_size_y=size_y; if(!DisplayElement()) return(false); return(true); } bool CControlElement :: CreateElement( ENUM_OBJECT type, // object type string name, // object name string description, // description of button text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color color col_select, // selected text color string font="Segoe UI Semibold", // font name int size_font=8, // font size int state=0, // state long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ) { m_chart_id=chart_id; // chart ID m_name=name; // object name m_window=window; // chart window m_num_points=1; // number of anchor points of object //--- Button parameters: m_corner=corner; // binding corner m_coord_x=coord_x; // X coordinate m_coord_y=coord_y; // Y coordinate //--- //--- Button parameters: m_type=type; m_description=description; // description m_size_x=size_x; // X size m_size_y=size_y; // Y size m_state=state; // state m_col_bg=col_bg; // background color m_col_font=col_font; // text color m_col_select=col_select; m_font=font; // font name m_size_font=size_font; // font size //--- return(true); } //+------------------------------------------------------------------+ //| Create a button | //| INPUT: ... | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: CreateButton( string name, // object name string description, // description or text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=8, // font size int state=0, // state long chart_id=0, // chart ID int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ) { m_chart_id=chart_id; // chart ID m_name=name; // object name m_window=window; // chart window m_num_points=1; // number of anchor points of object //--- Button parameters: m_corner=corner; // binding corner m_coord_x=coord_x; // X coordinate m_coord_y=coord_y; // Y coordinate //--- //--- Button parameters: m_type=OBJ_BUTTON; m_description=description; // object description or text m_size_x=size_x; // X size m_size_y=size_y; // Y size m_state=state; // state m_col_bg=col_bg; // background color m_col_font=col_font; // text color m_font=font; // font name m_size_font=size_font; // font size //--- if(!DisplayButton()) return(false); return(true); } //+------------------------------------------------------------------+ //| Create an Edit | //| INPUT: ... | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: CreateEdit( string name, // object name string text, // text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // border color string font="Segoe UI Semibold", // font name int size_font=8, // font size long chart_id=0, // chart id int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ) { m_chart_id=chart_id; // chart id m_name=name; // name m_description=text; m_window=window; // chart window m_num_points=1; // number of anchor points of object //--- Parameters: m_corner=corner; // binding corner m_coord_x=coord_x; // X coordinate m_coord_y=coord_y; // Y coordinate //--- //--- Edit field parameters: m_type=OBJ_EDIT; m_size_x=size_x; // X size m_size_y=size_y; // Y size m_col_bg=col_bg; // background color m_col_font=col_font; // border color m_font=font; // font name m_size_font=size_font; // font size //--- return(true); } //+------------------------------------------------------------------+ //| Show Edit field | //| INPUT: no. | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: DisplayBackground() { if(!Create(m_chart_id,m_name,m_window,m_coord_x,m_coord_y,m_size_x,m_size_y)) return(false); // Create edit if(!BackColor (m_col_bg)) return(false); // background color if(!Color(m_col_font)) return(false); // text color if(!Corner(m_corner)) return(false); // binding corner if(!Description(m_description)) return(false); // description if(!Font(m_font)) return(false); // font name if(!FontSize(m_size_font)) return(false); // font size if(!SetInteger(OBJPROP_READONLY,true)) return(false); return(true); } bool CControlElement :: CreateLabel( string name, // object name int coord_x, // X coordinate int coord_y, // Y coordinate color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=8, // font size long chart_id=0, // chart id int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ) { m_chart_id=chart_id; // chart id m_name=name; // object name m_window=window; // chart window m_num_points=1; // number of anchor points of object //--- label parameters: m_corner=corner; // binding corner m_coord_x=coord_x; // X coordinate m_coord_y=coord_y; // Y coordinate //--- //--- label parameters: m_type=OBJ_LABEL; m_col_font=col_font; // text color m_font=font; // font name m_size_font=size_font; // font size //--- // if(!DisplayLabel()) return(false); return(true); } //+------------------------------------------------------------------+ //| Show label | //| INPUT: no. | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: DisplayLabel() { if(!Create(m_chart_id,m_name,m_window,m_coord_x,m_coord_y)) return(false); // Create label if(!Font(m_font)) return(false); // font name if(!Color(m_col_font)) return(false); // text color if(!FontSize(m_size_font)) return(false); // font size if(!Corner(m_corner)) return(false); // binding corner return(true); } //+------------------------------------------------------------------+ //| Hide element | //| The hidden element can be show using Display method | //| Display() | //| INPUT: no. | //| OUTPUT: true - if successful | //| false - if error | //| REMARK: no. | //+------------------------------------------------------------------+ bool CControlElement :: Hide() { if(!ObjectDelete(m_chart_id,m_name)) return(false); return(true); } #include class CMenuHorizontal : public CList { protected: long m_chart_id; string m_name[]; string m_description[]; int m_chart_width; int m_size_x[]; int m_coord_y; int m_coord_x; int m_width; int m_height; int m_quantity_buttons; bool m_flag_status_message; bool m_flag_menu_horizontal; public: void CMenuHorizontal(); CObject *CreateElement( string name, // object name string description, // description or text int coord_x, // X coordinate int coord_y, // Y coordinate int size_x, // X size int size_y, // Y size color col_bg, // background color color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=8, // font size int state=0, // state long chart_id=0, // chart id int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ); bool Create( string& name_buttom[],// button names color col_bg, // background color color col_font, // text color string font="Segoe UI Semibold", // font name int size_font=10, // font size long chart_id=0, // chart id int window=0, // chart window ENUM_BASE_CORNER corner=CORNER_LEFT_LOWER // binding corner ); bool Delete(); void StatusMessage(string Message); bool GetFlagStatusMessage() {return(m_flag_status_message);} bool GetFlagMenuHorizontal() {return(m_flag_menu_horizontal);} int GetChartWidth() {return(m_chart_width);} bool AlignmentCenter(); bool Shift_x(int shift=0); bool Shift_y(int shift=0); bool HideStatusMessage(); bool DisplayStatusMessage(); bool HideMenuHorizontal(); bool DisplayMenuHorizontal(); }; void CMenuHorizontal :: CMenuHorizontal() { m_flag_status_message=true; m_flag_menu_horizontal=true; } bool CMenuHorizontal :: AlignmentCenter() { m_chart_width=(int)ChartGetInteger(m_chart_id,CHART_WIDTH_IN_PIXELS); int menu_x=(m_chart_width>(m_width+5))?(m_chart_width-m_width)/2:5; int shift=0; if (m_coord_x!=menu_x) { shift=menu_x-m_coord_x; m_coord_x=menu_x; Shift_x(shift); } return(true); } bool CMenuHorizontal :: Shift_x(int shift=0) { int total=Total(); CControlElement *element; for(int i=0;i(m_width+5))?(width_chart-m_width)/2:5; CControlElement *background=new CControlElement; if(!background.CreateEdit("background","",m_coord_x,m_coord_y-m_height-1,m_width,m_height-1,col_bg,col_bg,font,size_font))//col_font)) { Print(__FUNCTION__," Erro in creation of menu backround ",GetLastError()); delete background; return(false); } Add(background); if(!background.DisplayBackground()) return(false); for(int i=0,buttom_x=m_coord_x; i