Download MetaTrader 5
To add comments, please log in or register
Are you a good trader? Become a signals provider and make even more money!
andream1977
34
andream1977 2016.07.24 05:32 

 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);
      }
      

   }
Drazen Penic
2408
Drazen Penic 2016.07.24 10:32  

Try with ChartOpen()

 

long new_chart=ChartOpen(symbol,period);
/
To add comments, please log in or register