Buttons interfering with each other on Trade Panel

 

Hello guys.


Please I  built a trading panel.  

But the Amount and RR in Combo Box target 1 is interfering with the demand and supply buttons respectively. 

Please help me check what I'm doing wrong.

Thanks.

 
Osazee Asikhemhen:

Please help me check what I'm doing wrong.

How can anyone help you when you don't show your code????

 
This is the file
Files:
EA_GUI.mq4  41 kb
 
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "htTake_Profits://www.mql5.com"
#property version   "1.00"

//+------------------------------------------------------------------+
//| Includes                                                         |
//+------------------------------------------------------------------+
#include <Controls\Dialog.mqh>    
#include <Controls\Label.mqh>
#include <Controls\Panel.mqh>
#include <Controls\ComboBox.mqh>
#include <Controls\Button.mqh>
#include <Controls\CheckBox.mqh>

string  Draw_Rectangle_Supply;
string  Draw_Rectangle_Demand;
string  Draw_Rectangle;
string  Show;
double  Rect_width;
int     BarsAhead = 2;
int     TextBarsAhead=2;
int     TextSize=8; // text size for price & fib number
string  TextFont="Arial"; //text to use for display font
string  TP1, TP2, TP3, SL1, SL2, SL3;
//+------------------------------------------------------------------+
//| class CAppDialogExample                                          |
//+------------------------------------------------------------------+
class CAppDialogExample : public CAppDialog
  {
public:
   //--- chart event handler
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
               
private:
   //--- combo box change event
   void         OnChangeComboBox1();
   void         OnChangeComboBox2();
   void         OnChangeComboBox3();
   
   void         OnChangeComboBox4();
   void         OnChangeComboBox5();
   void         OnChangeComboBox6();

   
  };

//+------------------------------------------------------------------+
//| class CAppDialogExample1                                          |
//+------------------------------------------------------------------+
class CAppDialogExample1 : public CAppDialog
  {
public:
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);

private:
   //--- combo box change event
   void         OnClick_HideDialog(void); //{DialogBox3.Hide(); Print("Hide");}
   void         OnClick_ShowDialog(void);//{DialogBox3.Show(); Print("Show");}
  };
//+------------------------------------------------------------------+
//| class CAppDialogExample2                                         |
//+------------------------------------------------------------------+
class CAppDialogExample2 : public CAppDialog
  {
public:
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
   
private:
   //--- combo box change event
   void         OnClick_Demand();
   void         OnClick_Supply();
   void         OnClick_Edit();
   void         OnClick_Confirm();
   void         OnClick_Delete();
   void         OnClick_Execute();
   void         OnClick_ShowTP();
   void         OnClick_HideTP();
   void         OnClick_BE();
  };

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CAppDialogExample::OnChangeComboBox1(void)
{
   TP1 = Target1_Combo.Select();
}

void CAppDialogExample::OnChangeComboBox2(void)
{
   TP2 = Target2_Combo.Select();
}

void CAppDialogExample::OnChangeComboBox3(void)
{
   TP3 = Target3_Combo.Select();
}

void CAppDialogExample::OnChangeComboBox4(void)
{
   SL1 = SLCombo1.Select();
}

void CAppDialogExample::OnChangeComboBox5(void)
{
   SL2 = SLCombo2.Select();
}

void CAppDialogExample::OnChangeComboBox6(void)
{
   SL3 = SLCombo3.Select();
}

void CAppDialogExample2::OnClick_ShowTP(void)
{
   DialogBox1.Show();
}

void CAppDialogExample2::OnClick_HideTP(void)
{
   DialogBox1.Hide();
   Print("Hide TP");
}

void CAppDialogExample2::OnClick_BE(void)
{
      
}

void CAppDialogExample1::OnClick_HideDialog(void)
{
      DialogBox3.Hide();
      Print("Hide");
}

void CAppDialogExample1::OnClick_ShowDialog(void)
{
      DialogBox3.Show();
      Print("Show");
}

void CAppDialogExample2::OnClick_Supply(void)
{
      Draw_Rectangle="true"; Draw_Rectangle_Supply="true";
      Print("0_S");
}

void CAppDialogExample2::OnClick_Delete(void)
{
      Print("Delete");
      RectangleDelete(0, "Supply Zone");
      RectangleDelete(0, "Demand Zone");
}

void CAppDialogExample2::OnClick_Demand(void)
{
      Draw_Rectangle="true"; Draw_Rectangle_Demand="true";
      Print("0_D");
}


void CAppDialogExample2::OnClick_Edit(void)
{
      Print("Edit");
      if(ObjectFind(0, "Supply Zone")>=0)                                  ObjectSetInteger(0, "Supply Zone", OBJPROP_SELECTED, true);
      if(ObjectFind(0, "Demand Zone")>=0)                                  ObjectSetInteger(0, "Demand Zone", OBJPROP_SELECTED, true);
}

void CAppDialogExample2::OnClick_Execute(void)
{
      Order_Send();
}

void CAppDialogExample2::OnClick_Confirm(void)
{
      Print("Confirm");
      if(ObjectFind(0, "Supply Zone")>=0)                                  ObjectSetInteger(0, "Supply Zone", OBJPROP_SELECTED, false);
      if(ObjectFind(0, "Demand Zone")>=0)                                  ObjectSetInteger(0, "Demand Zone", OBJPROP_SELECTED, false);}






EVENT_MAP_BEGIN(CAppDialogExample)
ON_EVENT(ON_CHANGE,Target1_Combo,OnChangeComboBox1)
ON_EVENT(ON_CHANGE,Target2_Combo,OnChangeComboBox2)
ON_EVENT(ON_CHANGE,Target3_Combo,OnChangeComboBox3)
ON_EVENT(ON_CHANGE,SLCombo1,OnChangeComboBox4)
ON_EVENT(ON_CHANGE,SLCombo2,OnChangeComboBox5)
ON_EVENT(ON_CHANGE,SLCombo3,OnChangeComboBox6)
EVENT_MAP_END(CAppDialog)

EVENT_MAP_BEGIN(CAppDialogExample1)
ON_EVENT(ON_CLICK,HideDialogue,OnClick_HideDialog)
ON_EVENT(ON_CLICK,ShowDialogue,OnClick_ShowDialog)
EVENT_MAP_END(CAppDialog)

EVENT_MAP_BEGIN(CAppDialogExample2)
ON_EVENT(ON_CLICK,Supply,OnClick_Supply)
ON_EVENT(ON_CLICK,Demand,OnClick_Demand)
ON_EVENT(ON_CLICK,Edit,OnClick_Edit)
ON_EVENT(ON_CLICK,Confirm,OnClick_Confirm)
ON_EVENT(ON_CLICK,Delete,OnClick_Delete)
ON_EVENT(ON_CLICK,Execute,OnClick_Execute)
ON_EVENT(ON_CLICK,Show_Take_Profit,OnClick_ShowTP)
ON_EVENT(ON_CLICK,Hide_Take_Profit,OnClick_HideTP)
ON_EVENT(ON_CLICK,Break_Even,OnClick_BE)
EVENT_MAP_END(CAppDialog)

 
//+------------------------------------------------------------------+
//| Global variabels                                                 |
//+------------------------------------------------------------------+
//--- Panel itself
CAppDialogExample*    DialogBox1;
CAppDialogExample1*   DialogBox2;
CAppDialogExample2*   DialogBox3;

CPanel                Panel_Color, Panel2_Color, CheckPanel1, CheckPanel2, CheckPanel3;
CLabel                Risk_Label, Orders_Label, Target1_Label, Target2_Label, Target3_Label, CheckLabel1, CheckLabel2, CheckLabel3, SLLabel1, SLLabel2, SLLabel3;
CComboBox             Target1_Combo, Target2_Combo, Target3_Combo, CheckCombo1, CheckCombo2, CheckCombo3, SLCombo1, SLCombo2, SLCombo3;
CButton               Show_Take_Profit, Hide_Take_Profit, Break_Even, Demand, Supply, ShowDialogue, HideDialogue, Edit, Confirm, Execute, Delete;
CEdit                 Risk, Orders, Target1_Edit, Target2_Edit, Target3_Edit, CheckEdit1, CheckEdit2, CheckEdit3;
CCheckBox             CheckExit1, CheckExit2, CheckExit3;

//+------------------------------------------------------------------+
//| On Init                                                          |
//+------------------------------------------------------------------+
int OnInit() 
  {
DialogBox1=new CAppDialogExample();
DialogBox2=new CAppDialogExample1();
DialogBox3=new CAppDialogExample2();

DialogBox1.Create(0, "Dialog Box 1", 0, 340, 30, 780, 175);
DialogBox2.Create(0, "Dialog Box 2", 0, 8, 80,120, 134);
DialogBox3.Create(0, "Dialog Box 3", 0, 340, 30, 660, 220);


Panel_Color.Create(0,"Background Color",0, 0, 0, 432,117);
Panel_Color.ColorBackground(Black);
DialogBox1.Add(Panel_Color); 
   
ShowDialogue.Create(0, "SHOW", 0, 0, 0, 50, 25);
ShowDialogue.Text("SHOW");
ShowDialogue.Color(White);
ShowDialogue.ColorBackground(Black);
DialogBox2.Add(ShowDialogue);

HideDialogue.Create(0, "HIDE", 0, 55, 0, 103, 25);
HideDialogue.Text("HIDE");
HideDialogue.Color(White);
HideDialogue.ColorBackground(Black);
DialogBox2.Add(HideDialogue);

Panel2_Color.Create(0,"Background Panel Color",0, 0, 0, 313, 162);
Panel2_Color.ColorBackground(Black);
DialogBox3.Add(Panel2_Color);  

Risk_Label.Create(0, "Percentage Risk", 0, 15, 15, 20, 60);
Risk_Label.Text("Risk %");
Risk.Text("1");
Risk_Label.Color(White);
DialogBox3.Add(Risk_Label);

Risk.Create(0, "Percentage Risk_", 0, 15, 40, 55, 65);
Risk.Color(Black);
Risk.Text("1");
Risk.FontSize(10);
DialogBox3.Add(Risk);

Orders_Label.Create(0, "Orders_Label", 0, 80, 15, 110, 50);
Orders_Label.Text("Orders");
Orders_Label.Color(White);
DialogBox3.Add(Orders_Label);

Orders.Create(0, "Orders", 0, 80, 40, 120, 65);
Orders.Color(Black);
Orders.Text("5");
Orders.FontSize(10);
DialogBox3.Add(Orders);

Hide_Take_Profit.Create(0, "Hide TP Set.", 0, 215, 15, 300, 35);
Hide_Take_Profit.Text("Hide TP Set.");
DialogBox3.Add(Hide_Take_Profit);

Show_Take_Profit.Create(0, "Show TP Set.", 0, 130, 15, 210, 35);
Show_Take_Profit.Text("Show TP Set.");
DialogBox3.Add(Show_Take_Profit);

Break_Even.Create(0, "Break Even", 0, 130, 45, 300, 65);
Break_Even.Text("Break Even");
DialogBox3.Add(Break_Even);

Supply.Create(0, "Supply", 0, 15, 75, 95, 105);
Supply.Text("Supply");
Supply.Color(White);
Supply.ColorBackground(Crimson);
Supply.ColorBorder(Black);
DialogBox3.Add(Supply);


Demand.Create(0, "Demand", 0, 118, 75, 198, 105);
Demand.Text("Demand");
Demand.Color(White);
Demand.ColorBackground(clrDarkGreen);
Demand.ColorBorder(Black);
DialogBox3.Add(Demand);

Confirm.Create(0, "Confirm", 0, 15, 115, 95, 145);
Confirm.Text("Confirm");
DialogBox3.Add(Confirm);

Edit.Create(0, "Edit", 0, 220, 75, 300, 105);
Edit.Text("Edit");
DialogBox3.Add(Edit);

Delete.Create(0, "Delete", 0, 118, 115, 198, 145);
Delete.Text("Delete");
DialogBox3.Add(Delete);

Execute.Create(0, "Execute", 0, 220, 115, 300, 145);
Execute.Text("Execute");
DialogBox3.Add(Execute); 
    

Target1_Combo.Create(0, "Target1_List", 0, 70, 35, 130, 55);
Target1_Combo.ItemAdd("Pips");
Target1_Combo.ItemAdd("Price");
Target1_Combo.ItemAdd("Amount");
Target1_Combo.ItemAdd("RR");
Target1_Combo.Select(0);
DialogBox1.Add(Target1_Combo);

Target2_Combo.Create(0, "Target2_Combo", 0, 210, 35, 272, 56);
Target2_Combo.ItemAdd("Pips");
Target2_Combo.ItemAdd("Price");
Target2_Combo.ItemAdd("Amount");
Target2_Combo.ItemAdd("RR");
Target2_Combo.Select(0);
DialogBox1.Add(Target2_Combo);

Target3_Combo.Create(0, "Target3_List", 0, 356, 35, 422, 55);
Target3_Combo.ItemAdd("Pips");
Target3_Combo.ItemAdd("Price");
Target3_Combo.ItemAdd("Amount");
Target3_Combo.ItemAdd("RR");
Target3_Combo.Select(0);
DialogBox1.Add(Target3_Combo);  

Target1_Label.Create(0, "Target1_Label", 0, 8, 8, 100, 50);
Target1_Label.Text("TARGET 1:");
Target1_Label.FontSize(14);
Target1_Label.Color(White);
DialogBox1.Add(Target1_Label);

Target2_Label.Create(0, "Target1_Labe2", 0, 150, 8, 300, 50);
Target2_Label.Text("TARGET 2:");
Target2_Label.FontSize(14);
Target2_Label.Color(White);
DialogBox1.Add(Target2_Label);

Target3_Label.Create(0, "Target3_Label", 0, 300, 8, 400, 50);
Target3_Label.Text("TARGET 3:");
Target3_Label.FontSize(14);
Target3_Label.Color(White);
DialogBox1.Add(Target3_Label);

Target1_Edit.Create(0, "Target1_Edit", 0, 8, 35, 60, 55);
Target1_Edit.Color(Black);
Target1_Edit.Text("5");
Target1_Edit.FontSize(10);
DialogBox1.Add(Target1_Edit);

Target2_Edit.Create(0, "Target2_Edit", 0, 150, 35, 202, 55);
Target2_Edit.Color(Black);
Target2_Edit.Text("5");
Target2_Edit.FontSize(10);
DialogBox1.Add(Target2_Edit);

Target3_Edit.Create(0, "Target3_Edit", 0, 300, 35, 352, 55);
Target3_Edit.Color(Black);
Target3_Edit.Text("5");
Target3_Edit.FontSize(10);
DialogBox1.Add(Target3_Edit);

CheckExit1.Create(0, "C1", 0, 4, 62, 65, 80);
CheckExit1.Text("");
CheckExit1.Color(Black);
DialogBox1.Add(CheckExit1);

CheckPanel1.Create(0, "CheckPanel1", 0, 21, 55, 80, 117);
DialogBox1.Add(CheckPanel1);

CheckLabel1.Create(0, "CheckLabel1", 0, 25, 62, 65, 80);
CheckLabel1.Text("Exit %:");
CheckLabel1.FontSize(10);
CheckLabel1.Color(White);
DialogBox1.Add(CheckLabel1);

CheckEdit1.Create(0, "CheckEdit1", 0, 70, 62, 130, 82);
DialogBox1.Add(CheckEdit1);
 
CheckExit2.Create(0, "C2", 0, 150, 62, 208, 80);
CheckExit2.Text("");
CheckExit2.Color(Black);
DialogBox1.Add(CheckExit2);

CheckPanel2.Create(0, "CheckPanel2", 0, 167, 55, 222, 117);
DialogBox1.Add(CheckPanel2);

CheckLabel2.Create(0, "CheckLabel2", 0, 167, 62, 207, 80);
CheckLabel2.Text("Exit %:");
CheckLabel2.FontSize(10);
CheckLabel2.Color(White);
DialogBox1.Add(CheckLabel2);

CheckEdit2.Create(0, "CheckEdit2", 0, 210, 62, 272, 82);
DialogBox1.Add(CheckEdit2);

CheckExit3.Create(0, "CheckExit3", 0, 300, 62, 358, 80);
CheckExit3.Text("");
CheckExit3.Color(Black);
DialogBox1.Add(CheckExit3);

CheckPanel3.Create(0, "CheckPanel3", 0, 317, 55, 372, 117);
DialogBox1.Add(CheckPanel3);

CheckLabel3.Create(0, "CheckLabel3", 0, 317, 62, 357, 80);
CheckLabel3.Text("Exit %:");
CheckLabel3.FontSize(10);
CheckLabel3.Color(White);
DialogBox1.Add(CheckLabel3);

CheckEdit3.Create(0, "CheckEdit3", 0, 356, 62, 422, 82);
DialogBox1.Add(CheckEdit3);

SLLabel1.Create(0, "SLLabel1", 0, 8, 88, 20, 108);
SLLabel1.Text("SL:");
SLLabel1.FontSize(10);
SLLabel1.Color(White);
DialogBox1.Add(SLLabel1);

SLCombo1.Create(0, "SLCombo1", 0, 30, 88, 130, 108);
SLCombo1.ItemAdd("Pips");
SLCombo1.ItemAdd("Price");
SLCombo1.ItemAdd("Amount");
SLCombo1.ItemAdd("RR");
SLCombo1.Select(0);
DialogBox1.Add(SLCombo1);

SLLabel2.Create(0, "SLLabel2", 0, 150, 88, 162, 108);
SLLabel2.Text("SL:");
SLLabel2.FontSize(10);
SLLabel2.Color(White);
DialogBox1.Add(SLLabel2);

SLCombo2.Create(0, "SLCombo2", 0, 172, 88, 272, 108);
SLCombo2.ItemAdd("Pips");
SLCombo2.ItemAdd("Price");
SLCombo2.ItemAdd("Amount");
SLCombo2.ItemAdd("RR");
SLCombo2.Select(0);
DialogBox1.Add(SLCombo2);

SLLabel3.Create(0, "SLLabel3", 0, 300, 88, 312, 108);
SLLabel3.Text("SL:");
SLLabel3.FontSize(10);
SLLabel3.Color(White);
DialogBox1.Add(SLLabel3);

SLCombo3.Create(0, "SLCombo3", 0, 322, 88, 422, 108);
SLCombo3.ItemAdd("Pips");
SLCombo3.ItemAdd("Price");
SLCombo3.ItemAdd("Amount");
SLCombo3.ItemAdd("RR");
SLCombo3.Select(0);
DialogBox1.Add(SLCombo3);






//--- Run panel
   DialogBox1.Run();
   DialogBox2.Run();
   DialogBox3.Run();
   
   DialogBox3.Hide();
   DialogBox1.Hide();
   
   
   return(0);
  }
//+------------------------------------------------------------------+
//| On DeInit                                                        |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- Destroy panel
   DialogBox1.Destroy(reason);
   DialogBox2.Destroy(reason);
   DialogBox3.Destroy(reason);
   
   if(CheckPointer(DialogBox1)==POINTER_DYNAMIC) delete DialogBox1;
   if(CheckPointer(DialogBox2)==POINTER_DYNAMIC) delete DialogBox2;
   if(CheckPointer(DialogBox3)==POINTER_DYNAMIC) delete DialogBox3;
//--- Delete all objects
   ObjectsDeleteAll(0,0);
   
   string name="";
if(ObjectFind(name ) >= -1) ObjectsDeleteAll(); 
  }
//+------------------------------------------------------------------+
//| On Calculate                                                     |
//+------------------------------------------------------------------+
void OnTick()
  {

Print(TP1, ", ", TP2, ", ", TP3);


  }

//+------------------------------------------------------------------+
//| On Chart Event                                                   |
//+------------------------------------------------------------------+

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_CLICK && Draw_Rectangle=="true")
     {
         Print("2");
         //--- Prepare variables
         int      x     =(int)lparam;
         int      y     =(int)dparam;
         datetime dt    =0;
         double   price =0;
         int      window=0;
         
        //--- Convert the X and Y coordinates in terms of date/time
         if(ChartXYToTimePrice(0,x,y,window,dt,price))
           {
            if (Period()==PERIOD_M1)      Rect_width=1;
            if (Period()==PERIOD_M5)      Rect_width=3;
            if (Period()==PERIOD_M15)     Rect_width=5;
            if (Period()==PERIOD_M30)     Rect_width=10;
            if (Period()==PERIOD_H1)      Rect_width=25;
            if (Period()==PERIOD_H4)      Rect_width=70;
            if (Period()==PERIOD_D1)      Rect_width=120;
            if (Period()==PERIOD_W1)      Rect_width=150;
            if (Period()==PERIOD_MN1)     Rect_width=200;
           
            if (Draw_Rectangle_Supply=="true")
               {
                  RectangleCreate(0, "Supply Zone", 0, iTime(_Symbol, PERIOD_CURRENT, 20), price, TimeCurrent(), price-(Rect_width*Point()*10), Crimson, STYLE_SOLID, 2, true, true, true, false, 0);
                  Draw_Rectangle_Supply=" ";
               }
               
            if (Draw_Rectangle_Demand=="true")
               {
                  RectangleCreate(0, "Demand Zone", 0, iTime(_Symbol, PERIOD_CURRENT, 20), price, TimeCurrent(), price-(Rect_width*Point()*10), clrDarkGreen, STYLE_SOLID, 2, true, true, true, false, 0);
                  Draw_Rectangle_Demand=" ";
               }
            Draw_Rectangle=" ";
            ChartRedraw(0);
           }
         else
            Print("ChartXYToTimePrice return error code: ",GetLastError());
     }


  
  
  
//--- Move the panel with the mouse
   DialogBox1.ChartEvent(id,lparam,dparam,sparam);
   DialogBox2.ChartEvent(id,lparam,dparam,sparam);
   DialogBox3.ChartEvent(id,lparam,dparam,sparam);
 
 if(id==CHARTEVENT_CLICK && Draw_Rectangle=="true") 

Where do you check for what was clicked?

 
William Roeder #:

Where do you check for what was clicked?





void CAppDialogExample2::OnClick_Supply(void)


{


      Draw_Rectangle="true"; Draw_Rectangle_Supply="true";


      Print("0_S");


}




void CAppDialogExample2::OnClick_Demand(void)


{


      Draw_Rectangle="true"; Draw_Rectangle_Demand="true";


      Print("0_D");


}

 


This is what I described