Download MetaTrader 5

ObjectCreate

To add comments, please log in or register
jshumaker
507
jshumaker 2013.04.14 18:07 

I have working code that creates arrows on my chart, but I wanted to start putting text on my charts instead of arrows.  I cannot get the text to show up on my charts.  

WORKING CODE

      ObjectCreate(0, "arrow" + TimeToString(TimeCurrent()),OBJ_ARROW_SELL,0,TimeCurrent(),H1wave.High());
      ObjectSetInteger(0,"arrow" + TimeToString(TimeCurrent()),OBJPROP_COLOR,clrDarkSeaGreen); 

 FAILED CODE

 

      ObjectCreate(0, "arrow" + TimeToString(TimeCurrent()),OBJ_LABEL,0,TimeCurrent(),H1wave.Low());
      ObjectSetInteger(0,"arrow" + TimeToString(TimeCurrent()),OBJPROP_COLOR,clrAqua);   
      ObjectSetString(0,"arrow" + TimeToString(TimeCurrent()),OBJPROP_TEXT,"A");
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.04.14 18:55  
jshumaker:

I have working code that creates arrows on my chart, but I wanted to start putting text on my charts instead of arrows.  I cannot get the text to show up on my charts.  

Don't call TimeCurrent() multiple times or you may find that it changes between calls and then you will have a strange situation . . .  also you don't need to call TimeTostring() at all.  Just use a string to store the Object name . . .

string TextObjName = "arrow" + TimeCurrent();

ObjectCreate(0, TextObjName, OBJ_LABEL, 0, TimeCurrent(), H1wave.Low());

 also,  your code is different,  in the working code you use  H1wave.High()  in the failed code you use  H1wave.Low(),  maybe this function is the problem ?  or maybe angevoyageur  is correct ;-)

Use   OBJ_TEXT  instead. 

Alain Verleyen
Moderator
31085
Alain Verleyen 2013.04.14 18:56  
jshumaker:

I have working code that creates arrows on my chart, but I wanted to start putting text on my charts instead of arrows.  I cannot get the text to show up on my charts.  

WORKING CODE

 FAILED CODE

 

Label object need X,Y coordinates not time, date.

See an example in the bottom of this page.

jshumaker
507
jshumaker 2013.04.14 20:10  
RaptorUK:

Don't call TimeCurrent() multiple times or you may find that it changes between calls and then you will have a strange situation . . .  also you don't need to call TimeTostring() at all.  Just use a string to store the Object name . . .

 also,  your code is different,  in the working code you use  H1wave.High()  in the failed code you use  H1wave.Low(),  maybe this function is the problem ?  or maybe angevoyageur  is correct ;-)

Use   OBJ_TEXT  instead. 

OBJ_LABEL

jshumaker
507
jshumaker 2013.04.14 20:11  
jshumaker:

   string objName = "arrow" + TimeCurrent();
   if (H1pool.Direction() != -1 && H1pool.MacdBar(1) < H1pool.MacdSignal(1))
   {  H1pool.Direction(-1);
      ObjectCreate(0, objName,OBJ_LABEL,0,TimeCurrent(),H1wave.Low());
      ObjectSetInteger(0,objName,OBJPROP_COLOR,clrWhite);   
      ObjectSetString(0,objName,OBJPROP_TEXT,"A");    
      H1wave.Calc(m_symbol.Bid(), true);  }
   else if (H1pool.Direction() != 1 && H1pool.MacdBar(1) > H1pool.MacdSignal(1))
   {  H1pool.Direction(1);
      ObjectCreate(0, objName,OBJ_ARROW_SELL,0,TimeCurrent(),H1wave.Low());
      ObjectSetInteger(0,objName,OBJPROP_COLOR,clrDarkSeaGreen); 
      H1wave.Calc(m_symbol.Bid(), true);  }
this code produces the above chart.  I would like the text to show like the arrow does, which is when the macd & signal are confirmed crossing
Alain Verleyen
Moderator
31085
Alain Verleyen 2013.04.14 20:24  
jshumaker:
this code produces the above chart.  I would like the text to show like the arrow does, which is when the macd & signal are confirmed crossing
Do you read the response when you ask a question ?
jshumaker
507
jshumaker 2013.04.14 20:44  
angevoyageur:
Do you read the response when you ask a question ?
huh?  I tried what raptor suggested
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.04.14 20:46  
jshumaker:
huh?  I tried what raptor suggested
RaptorUK:


Use   OBJ_TEXT  instead. 

Alain Verleyen
Moderator
31085
Alain Verleyen 2013.04.14 20:50  
jshumaker:
huh?  I tried what raptor suggested
You continue with OBJ_LABEL and time/price coordinates. If you want to use OBJ_LABEL then use x,y coordinates. Otherwise, as Raptor said you use OBJ_TEXT. It's more clear ?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Properties - Documentation on MQL5
jshumaker
507
jshumaker 2013.04.14 20:50  
jshumaker:
huh?  I tried what raptor suggested

never mind.  i see i did not change it to object_text, DUH 

To add comments, please log in or register