how to open a chart from button click

 

 hi

wi would open a eurusd mt4 chart when a click a button, this is my code that show a button, when i click it, it's does not open any chart of eurusd, where is my error?

 

#define WM_COMMAND   0x0111

string eurusdButton = "eurusdButton";

int OnInit() {
   ObjectCreate(0,eurusdButton,OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,eurusdButton,OBJPROP_XDISTANCE,10);
   ObjectSetInteger(0,eurusdButton,OBJPROP_YDISTANCE,30);
   ObjectSetInteger(0,eurusdButton,OBJPROP_XSIZE,60);
   ObjectSetInteger(0,eurusdButton,OBJPROP_YSIZE,25);
   ObjectSetString(0,eurusdButton,OBJPROP_TEXT,"EURUSD");
   ObjectSetInteger(0,eurusdButton,OBJPROP_CORNER,CORNER_LEFT_LOWER);
}

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
   {
   if(sparam==eurusdButton) 
      {
      int hTerminal = GetAncestor(WindowHandle("EURUSD", Period()), 2);
      PostMessageA(hTerminal, WM_COMMAND, 33160, 0);
      }
      

   }
 

Try with ChartOpen()

 

long new_chart=ChartOpen(symbol,period);