Help: How to make ObjectSetText display string variable

 

As I usually am trading and/or testing multiple strategies at one time, I am attempting to write a simple indicator that will display the strategy name in the top right corner of the chart. l Have been thus far successful with the attached code however; I have to hard code the strategy name within the code. I have a global variable which will allow me the standard ability to edit the indicator and type the new name into the properties window but, can not figure out how to replace the "hardcoded" name with the value the user inputs.

Any suggestions?

//| Custom indicator initialization function |\par

//+------------------------------------------------------------------+\par

int init()\par

\{\par

//---- indicators\par

//----\par

string StrategyName = Strategy_Name;\par

ObjectCreate("Strategy_Name", OBJ_LABEL,0,0,0,0,0);\par

ObjectSet("Strategy_Name",OBJPROP_CORNER,1);\par

ObjectSet("Strategy_Name",OBJPROP_YDISTANCE,5);\par

ObjectSetText("Strategy_Name","Bobs Strategy",14,"Tahoma",Red);\par

return(0);\par

\}\par

 
Boham:

As I usually am trading and/or testing multiple strategies at one time, I am attempting to write a simple indicator that will display the strategy name in the top right corner of the chart. l Have been thus far successful with the attached code however; I have to hard code the strategy name within the code. I have a global variable which will allow me the standard ability to edit the indicator and type the new name into the properties window but, can not figure out how to replace the "hardcoded" name with the value the user inputs.

Any suggestions?

  Hi Boham, 

  • Use WindowExpertName() & you will never have to type/hard-code you experts name again... ever! Make a copy & rename your indy as the strategy & insert the function to ObjectCreate.
  • And you can use the GV to do this trick :  make the GV count how many expert(s) are attached to the chart & have the count multiplied with YDISTANCE so the name would automatically aligned to lower distant then previous one.  

 cameo 

 
cameofx:

Hi Boham,

  • Use WindowExpertName() & you will never have to type/hard-code you experts name again... ever! Make a copy & rename your indy as the strategy & insert the function to ObjectCreate.
  • And you can use the GV to do this trick : make the GV count how many expert(s) are attached to the chart & have the count multiplied with YDISTANCE so the name would automatically aligned to lower distant then previous one.

cameo


Thanks for the input cameofx, I have solved the issue!