Why doesn't display label number change when value changes in MQL4?
Why doesn't display label number change when value changes in MQL4?
Loading saved threads...
user16172780 · External communityPost link
External question — Stack Overflow Stack Exchange
Author: user16172780
Original post: https://stackoverflow.com/questions/68634341
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Here is a function to create a button.
void CreateLabel(string labelname,string label,int xsize,int ysize,int xdist,int ydist,int bcolor,int fcolor) {
if(ObjectFind(0,labelname)<0) {
if(!ObjectCreate(0,labelname,OBJ_BUTTON,0,0,0)) {
Print(__FUNCTION__,
": failed to create the button! Error code = ",GetLastError());
return;
}
ObjectSetString(0,labelname,OBJPROP_TEXT,label);
ObjectSetInteger(0,labelname,OBJPROP_XSIZE,xsize);
ObjectSetInteger(0,labelname,OBJPROP_YSIZE,ysize);
ObjectSetInteger(0,labelname,OBJPROP_CORNER,CORNER_LEFT_UPPER);
ObjectSetInteger(0,labelname,OBJPROP_XDISTANCE,xdist);
ObjectSetInteger(0,labelname,OBJPROP_YDISTANCE,ydist);
ObjectSetInteger(0,labelname,OBJPROP_BGCOLOR,bcolor);
ObjectSetInteger(0,labelname,OBJPROP_COLOR,fcolor);
ObjectSetInteger(0,labelname,OBJPROP_FONTSIZE,8);
ObjectSetInteger(0,labelname,OBJPROP_HIDDEN,true);
//ObjectSetInteger(0,but_name,OBJPROP_BORDER_COLOR,ChartGetInteger(0,CHART_COLOR_FOREGROUND));
ObjectSetInteger(0,labelname,OBJPROP_BORDER_TYPE,BORDER_FLAT);
ChartRedraw();
}
}
Here is function call
CreateLabel("EUROCSH4",IntegerToString(EUROCSH4,2),50 ,18,basket_x+i ,basket_y+40,C'35,35,35',clrWhite);
but when I call the function to change the OBJPROP_TEXT it doesn't change.
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/68652992
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Change your function to:
void CreateLabel(string labelname,string label,int xsize,int ysize,int xdist,int ydist,int bcolor,int fcolor)
{
if(ObjectFind(0,labelname)<0)
{
if(!ObjectCreate(0,labelname,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,": failed to create the button! Error code = ",GetLastError());
return;
}
ObjectSetString(0,labelname,OBJPROP_TEXT,label);
ObjectSetInteger(0,labelname,OBJPROP_XSIZE,xsize);
ObjectSetInteger(0,labelname,OBJPROP_YSIZE,ysize);
ObjectSetInteger(0,labelname,OBJPROP_CORNER,CORNER_LEFT_UPPER);
ObjectSetInteger(0,labelname,OBJPROP_XDISTANCE,xdist);
ObjectSetInteger(0,labelname,OBJPROP_YDISTANCE,ydist);
ObjectSetInteger(0,labelname,OBJPROP_BGCOLOR,bcolor);
ObjectSetInteger(0,labelname,OBJPROP_COLOR,fcolor);
ObjectSetInteger(0,labelname,OBJPROP_FONTSIZE,8);
ObjectSetInteger(0,labelname,OBJPROP_HIDDEN,true);
ObjectSetInteger(0,labelname,OBJPROP_BORDER_TYPE,BORDER_FLAT);
ChartRedraw();
}
else
{
ObjectSetString(0,labelname,OBJPROP_TEXT,label);
}
}
Quote
Report
Post Reply
Checking account access…