Displaying variable with formatting on a chart

 

Just a beginner...

Would this be the most efficient way of displaying the value of a variable on a chart in a script or expert? Note I don't want to use Comment() because font is too small. If there is a more efficient way, please describe. Thanks

//--------------------------------------

double prof = AccountProfit();

ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
ObjectSetText("ObjName",("Account Profit: " + prof), 16, "Arial", Yellow);
ObjectSet("ObjName", OBJPROP_CORNER, 0);
ObjectSet("ObjName", OBJPROP_XDISTANCE, 20);
ObjectSet("ObjName", OBJPROP_YDISTANCE, 20);

//--------------------------------------

 
mobmanager:

Just a beginner...

Would this be the most efficient way of displaying the value of a variable on a chart in a script or expert? Note I don't want to use Comment() because font is too small. If there is a more efficient way, please describe. Thanks


Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.

 
mobmanager:

Just a beginner...

Would this be the most efficient way of displaying the value of a variable on a chart in a script or expert? Note I don't want to use Comment() because font is too small. If there is a more efficient way, please describe. Thanks

If you try to create an object that already exists you will get an error . . . before you create it you should check to see if it exists, use ObjectFind(), if it does exist just change it's text using ObjectSetText()
Reason: