ObjectCreate mq5

 

seems about once every 10 or so years i have a gee whiz type question.....

ObjectCreate is pretty straight forward and can never recall a problem.....  till i noticed on currency futures the objectcreate will not create the buttons in the code below.....  i have googled and mq5 booked it to death.....

it will work perfectly on everything else.....  on currency futures it returns error 4101, wrong chart id.....  have never noticed that error before.....

including the chart_id just leads to cascading errors......

i'm still working on it, but does anyone have an idea....... it's mq5, not mq4...... thanks......h


int OnInit()
  {
//---

 
 
 long id = ChartID();
 
/*
 ObjectCreate(_Symbol,"test",OBJ_BUTTON,0,0,0))                                        //  this will not work on currency futures
 
 ObjectSetInteger(_Symbol,"test",OBJPROP_XDISTANCE,300);
 
 ObjectSetInteger(_Symbol,"test",OBJPROP_XSIZE,200);

 ObjectSetInteger(_Symbol,"test",OBJPROP_YDISTANCE,50);

 ObjectSetInteger(_Symbol,"test",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(_Symbol,"test",OBJPROP_CORNER,0); 

 ObjectSetString(_Symbol,"test",OBJPROP_TEXT,"test"); 
 
 ObjectSetInteger(_Symbol,"test",OBJPROP_BGCOLOR,clrAqua); 
 
*/

 if(!ObjectCreate(id,_Symbol,"test",OBJ_BUTTON,0,0,0)) {Print(GetLastError()+ ChartID());}        // this is just one of my attempts  here i used chart id

 
 ObjectSetInteger(id,_Symbol,"test",OBJPROP_XDISTANCE,300);
 
 ObjectSetInteger(id,_Symbol,"test",OBJPROP_XSIZE,200);

 ObjectSetInteger(id,_Symbol,"test",OBJPROP_YDISTANCE,50);

 ObjectSetInteger(id,_Symbol,"test",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(id,_Symbol,"test",OBJPROP_CORNER,0); 

 ObjectSetString(id,_Symbol,"test",OBJPROP_TEXT,"test"); 
 
 ObjectSetInteger(id,_Symbol,"test",OBJPROP_BGCOLOR,clrAqua);
 


 ObjectCreate(_Symbol,"Buy",OBJ_BUTTON,0,0,0);                      // this works ..... brief code, but it has always worked except on currency futures

 ObjectCreate(_Symbol,"Buy Limit",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Buy Stop",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Sell",OBJ_BUTTON,0,0,0);

 ObjectCreate(_Symbol,"Sell Limit",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Sell Stop",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Close",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Close All",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(_Symbol,"Profit",OBJ_BUTTON,0,0,0); 
 
 
//----
//---- 
 
 ObjectSetInteger(_Symbol,"Buy",OBJPROP_XDISTANCE,10);
 
 ObjectSetInteger(_Symbol,"Buy",OBJPROP_XSIZE,200);

 ObjectSetInteger(_Symbol,"Buy",OBJPROP_YDISTANCE,50);

 ObjectSetInteger(_Symbol,"Buy",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(_Symbol,"Buy",OBJPROP_CORNER,0); 

 ObjectSetString(_Symbol,"Buy",OBJPROP_TEXT,"Buy"); 
 
 ObjectSetInteger(_Symbol,"Buy",OBJPROP_BGCOLOR,clrAqua);
 

//---- 
 
 

when all else fails, search whroeder's posts......


case solved..... even though my prior code had always worked, perhaps it was not correct...


still not clear why only currency futures were effected.....   might look into it deeper...... might not......h

//-----

 ObjectCreate(0,"Buy",OBJ_BUTTON,0,0,0);

 ObjectCreate(0,"Buy Limit",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Buy Stop",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Sell",OBJ_BUTTON,0,0,0);

 ObjectCreate(0,"Sell Limit",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Sell Stop",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Close",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Close All",OBJ_BUTTON,0,0,0);
 
 ObjectCreate(0,"Profit",OBJ_BUTTON,0,0,0); 
 
 
//----
//---- 
 
 ObjectSetInteger(0,"Buy",OBJPROP_XDISTANCE,10);   //  ObjectSetInteger(0, ......  using _Symbol had always worked however on currency futures it did not..... must use '0'...... 
 
 ObjectSetInteger(0,"Buy",OBJPROP_XSIZE,200);

 ObjectSetInteger(0,"Buy",OBJPROP_YDISTANCE,50);

 ObjectSetInteger(0,"Buy",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(0,"Buy",OBJPROP_CORNER,0); 

 ObjectSetString(0,"Buy",OBJPROP_TEXT,"Buy"); 
 
 ObjectSetInteger(0,"Buy",OBJPROP_BGCOLOR,clrAqua);
 
are you returning INIT_SUCCEEDED from OnInit()? because it's important to do that for successful initialization when you use int OnInit() and not void OnInit()
 
Conor Mcnamara #:
are you returning INIT_SUCCEEDED from OnInit()? because it's important to do that for successful initialization when you use int OnInit() and not void OnInit()

//----


hey conor.......  thanks for the reply...... yes i am.....


mentioned over on enivids site that had thought it might have to do with futures starting with a 6..... 


enivid agreed..... it was a compound error on my part which just by chance had always worked ok before......


and again, thanks for the reply......h