how to open a chart from button click

Back to topics list To post a new topic, please log in or register
avatar
6
andream1977 2016.07.24 07: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);
      }
      

   }

 

avatar
164
drazen64 2016.07.24 12:32 #
 

Try with ChartOpen()

 

long new_chart=ChartOpen(symbol,period);

 

 

avatar
13001
Back to topics list  

To add comments, please log in or register