Hello my friends,
Could you please help me to make this code better.**
I succeeded at building a Menu for my EA that help me to view important information. the Menu look like this:
I want to add a rectangle frame to the background so it will look like this:
Here is the code of the Menu:
//===Choose to show or hide Menu
#define SHOW 0
#define HIDE 1
enum SH { Show,Hide };
//---Expert Proprities
extern SH ShowMenu = SHOW;
extern double LOTSIZE = 0.01;
extern int Profit = 50;
extern int StopLoss = 50;
extern color MenuColor = clrWhite;
extern int MenuFont = 11;
extern int MagicNumber = 0;
//---initialize global variables
int medzera,i;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
if(ShowMenu == SHOW)
{
DrawMenu();
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if(ShowMenu == SHOW)
{
ObjectDelete("LotLabel");
ObjectDelete("TPLabel");
ObjectDelete("SPLabel");
ObjectDelete("LotValue");
ObjectDelete("TPValue");
ObjectDelete("SPValue");
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//---Show or hide Menu
if(ShowMenu == SHOW)
{
ReDrawMenu();
}
return(0);
}
//+------------------------------------------------------------------+
//| DRAW MENU OBJECTS FUNCTIONS |
//+------------------------------------------------------------------+
//--- Function to draw Menu for the first time
bool DrawMenu()
{
medzera = 8;
//--- Create Labels Cells
ObjectCreate("LotLabel",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("TPLabel",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("SPLabel",OBJ_LABEL,0,0,0,0,0);
//---Modify Label Cells
ObjectSetText( "LotLabel", "Lot Size: " , MenuFont, "Arial", MenuColor);
ObjectSet("LotLabel",OBJPROP_XDISTANCE,medzera * MenuFont);
ObjectSet("LotLabel",OBJPROP_YDISTANCE,10+1*MenuFont);
ObjectSet("LotLabel",OBJPROP_CORNER,1);
ObjectSetText("TPLabel", "Take Profit in Pips: ", MenuFont, "Arial",MenuColor);
ObjectSet("TPLabel",OBJPROP_XDISTANCE,medzera * MenuFont);
ObjectSet("TPLabel",OBJPROP_YDISTANCE,15+2*(MenuFont+2));
ObjectSet("TPLabel",OBJPROP_CORNER,1);
ObjectSetText("SPLabel", "Stop Loss in Pips: ", MenuFont, "Arial",MenuColor);
ObjectSet("SPLabel",OBJPROP_XDISTANCE,medzera * MenuFont);
ObjectSet("SPLabel",OBJPROP_YDISTANCE,20+3*(MenuFont+2));
ObjectSet("SPLabel",OBJPROP_CORNER,1);
//--- Create Numerical Value Cells
ObjectCreate("LotValue",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("TPValue",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("SPValue",OBJ_LABEL,0,0,0,0,0);
//--- Modify numerical Value Cells
ObjectSetText("LotValue", ""+ LOTSIZE, MenuFont, "Arial",MenuColor);
ObjectSet("LotValue",OBJPROP_XDISTANCE, 3 * MenuFont);
ObjectSet("LotValue",OBJPROP_YDISTANCE,10+1*(MenuFont+2));
ObjectSet("LotValue",OBJPROP_CORNER,1);
ObjectSetText("TPValue"," "+Profit, MenuFont, "Arial",MenuColor);
ObjectSet("TPValue",OBJPROP_XDISTANCE,3 * MenuFont);
ObjectSet("TPValue",OBJPROP_YDISTANCE,15+2*(MenuFont+2));
ObjectSet("TPValue",OBJPROP_CORNER,1);
ObjectSetText("SPValue", " "+ StopLoss, MenuFont, "Arial",MenuColor);
ObjectSet("SPValue",OBJPROP_XDISTANCE,3 * MenuFont);
ObjectSet("SPValue",OBJPROP_YDISTANCE,20+3*(MenuFont+2));
ObjectSet("SPValue",OBJPROP_CORNER,1);
return(0);
}
//--- Function to redraw Menu on each tick
bool ReDrawMenu()
{
medzera = 8;
ObjectSetText("LotValue", ""+LOTSIZE, MenuFont, "Arial",MenuColor);
ObjectSetText("TPValue", Profit, MenuFont, "Arial",MenuColor);
ObjectSetText("SPValue", StopLoss, MenuFont, "Arial",MenuColor);
return(0);
}
Files: Draw_Menu_TEST.mq4 5 KB