I am trying to pass a variable (Count) as the Text of my Label. Whenever I try to use any Variable as the Text is just shows "0". If I pass a number or text then it works just fine. I am sorry if this is simple but I am new to MT5, on MT4 I used to do it all the time no problems.
I can't see anything wrong with your code except
Where do you assign a value to the variable Count?
Count=0; for(i=limit;i<rates_total-3 && !IsStopped();i++){ if(....){Count=Count+1;} } Label("Counting", IntergertoString(Count,0,0));
This is how I got my Count value.
its part of a loop that I know works because I tested it with Print(Count); and it returned the correct number in the toolbox
Then try this as your code will not change the text if the object already exists
bool Label(string label_name,string num){ if(ObjectFind(0,label_name)<0){ ObjectCreate(0,label_name,OBJ_LABEL,0,0,0); ObjectSetInteger(0,label_name,OBJPROP_CORNER,3); ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,100); ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,30); ObjectSetInteger(0,label_name,OBJPROP_COLOR,YellowGreen); ObjectSetString(0,label_name,OBJPROP_FONT,"Arial"); ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,14); ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,false); ChartRedraw(0);} ObjectSetString(0,label_name,OBJPROP_TEXT,num); return(true);}
if(....){Count=Count+1;}
}
Label("Counting", IntergertoString(Count,0,0));
This is how I got my Count value.
Please edit your post and use the code button (Alt+S)
Then try this as your code will not change the text if the object already exists
You sir are a genius...that was 3 hours of wasted frustration. It works now.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to pass a variable (Count) as the Text of my Label. Whenever I try to use any Variable as the Text is just shows "0". If I pass a number or text then it works just fine. I am sorry if this is simple but I am new to MT5, on MT4 I used to do it all the time no problems.