Arrow with Text Question

 

The following code allows you to place an arrow, at a specific candle, at a specific time.  I wanted to know if there is a way to display a value, ( text ) above a down arrow and below an up arrow?  Which will signify the value at that point.

       ObjectCreate("UpSymbolAz"+i, OBJ_ARROW, 0, Time[i],vH+_Point+_Point);         
       ObjectSet("UpSymbolAz"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
       ObjectSet("UpSymbolAz"+i, OBJPROP_WIDTH,2);       
       ObjectSet("UpSymbolAz"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolAz"+i, OBJPROP_ANCHOR, ANCHOR_BOTTOM); 
 

The OBJ_ARROW itself, does not have that property, but you can easily add an OBJ_TEXT at the same anchor point with the text you desire, such as the value of the Arrow.

See the following for an example: https://docs.mql4.com/constants/objectconstants/enum_object/obj_text

 
Have the arrow show the text when you mouse over it. Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference

OBJPROP_TOOLTIP

The text of a tooltip. If the property is not set, then the tooltip generated automatically by the terminal is shown. A tooltip can be disabled by setting the "\n" (line feed) value to it

string

 
Would it be written like this?  This draws the arrow and puts the word "TEXT" next to the arrow, but doesn't put the value for diff under the arrow.  Which is what I'm shooting for.
  if ( diff <= (-4.0) )
   {   
   
       ObjectCreate("UpSymbolBz"+i, OBJ_ARROW, 0, Time[i],vL+_Point+_Point);         
       ObjectSet("UpSymbolBz"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWUP); 
       ObjectSet("UpSymbolBz"+i, OBJPROP_WIDTH,2);       
       ObjectSet("UpSymbolBz"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolBz"+i, OBJPROP_ANCHOR, ANCHOR_TOP); 
      
       
       ObjectCreate("UpSymbolBy"+i, OBJ_TEXT, 0, Time[i],vL+_Point+_Point+_Point+_Point);         
       ObjectSet("UpSymbolBy"+i, OBJPROP_TEXT, diff);
       ObjectSet("UpSymbolBy"+i, OBJPROP_FONT,"Tahoma");       
       ObjectSet("UpSymbolBy"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolBy"+i, OBJPROP_ANCHOR, ANCHOR_TOP);  
       
       
   }   
 

"diff" is not a "string" (probably a "double"), so maybe you should convert it to a "string", with the "DoubleToString()" function, before using it to set the text property.

PS! A screenshot may also help in case we are misunderstanding you!

 

Thanks, FMIC, for all your help.  Tried a couple of options with DoubleToStr(), but still get same outcome.

   if ( diff >= 4.0 )
   {   
       textB = DoubleToStr(NormalizeDouble(diff,5),1);
   
       ObjectCreate("UpSymbolAz"+i, OBJ_ARROW, 0, Time[i],vH+_Point+_Point);         
       ObjectSet("UpSymbolAz"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
       ObjectSet("UpSymbolAz"+i, OBJPROP_WIDTH,2);       
       ObjectSet("UpSymbolAz"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolAz"+i, OBJPROP_ANCHOR, ANCHOR_BOTTOM); 
       textA = "HERE Down";
       
       
       ObjectCreate("UpSymbolAy"+i, OBJ_TEXT, 0, Time[i],vH+_Point+_Point+_Point+_Point);         
       ObjectSet("UpSymbolAy"+i, OBJPROP_TEXT, textB);
       ObjectSet("UpSymbolAy"+i, OBJPROP_FONT,"Tahoma");       
       ObjectSet("UpSymbolAy"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolAy"+i, OBJPROP_ANCHOR, ANCHOR_BOTTOM);       
       
       
       
       
   }


       
       

Here's the screen shot.

 

Use the ObjectSetString() not ObjectSet() with the "OBJPROP_TEXT". It is a string not a double.

You don't need NormalizeDouble() inside a DoubleToString(). It already has a "Digits" parameter. Also, DoubleToStr is the old MQL4 name. Use the newer name to be compatible with MQL5.

PS! Alternatively you can also use "ObjectSetText()" which sets various properties in one go.

 
       textB = "      "+ DoubleToStr(NormalizeDouble(diff,5),1);


       ObjectCreate("UpSymbolAy"+i, OBJ_TEXT, 0, Time[i],vH+_Point+_Point+_Point+_Point);  
       ObjectSetText("UpSymbolAy"+i, textB);
       ObjectSet("UpSymbolAy"+i, OBJPROP_FONT,"Tahoma");       
       ObjectSet("UpSymbolAy"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolAy"+i, OBJPROP_ANCHOR, ANCHOR_LEFT);    
       ObjectSet("UpSymbolAy"+i, OBJPROP_ANGLE, 90);     

Maybe not the solution you want

 

Thank you FMIC and GumRai for all your help!  You got me pointed in the right direction.  After a bit of trial and error, and a little cheating, I got it.

Here is the working code.  Not sure if there is a better or more correct way of doing this.


   if ( diff >= 4.0 )
   {   
    
       ObjectCreate("UpSymbolAz"+i, OBJ_ARROW, 0, Time[i],vH);         
       ObjectSet("UpSymbolAz"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
       ObjectSet("UpSymbolAz"+i, OBJPROP_WIDTH,2);       
       ObjectSet("UpSymbolAz"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolAz"+i, OBJPROP_ANCHOR, ANCHOR_BOTTOM); 
               
           
       textB = DoubleToStr(NormalizeDouble(diff,5),0);

       ObjectCreate("UpSymbolAy"+i, OBJ_TEXT, 0, Time[i],vM);  
       ObjectSetText("UpSymbolAy"+i, textB);
       ObjectSet("UpSymbolAy"+i, OBJPROP_FONT,"Tahoma");       
       ObjectSet("UpSymbolAy"+i, OBJPROP_COLOR,Lime);
       ObjectSet("UpSymbolAy"+i, OBJPROP_ANCHOR, ANCHOR_CENTER);    
       ObjectSet("UpSymbolAy"+i, OBJPROP_ANGLE, 360); 
       
              
   }    

   
   if ( diff <= (-4.0) )
   {   
                          
       textB = DoubleToStr(NormalizeDouble(diff,5),0);    
       
       ObjectCreate("UpSymbolBy"+i, OBJ_TEXT, 0, Time[i],vN);  
       ObjectSetText("UpSymbolBy"+i, textB);
       ObjectSet("UpSymbolBy"+i, OBJPROP_FONT,"Tahoma");       
       ObjectSet("UpSymbolBy"+i, OBJPROP_COLOR,Red);
       ObjectSet("UpSymbolBy"+i, OBJPROP_ANCHOR, ANCHOR_CENTER);    
       ObjectSet("UpSymbolBy"+i, OBJPROP_ANGLE, 360); 
              
       
       ObjectCreate("UpSymbolBz"+i, OBJ_ARROW, 0, Time[i],vL);         
       ObjectSet("UpSymbolBz"+i, OBJPROP_ARROWCODE, SYMBOL_ARROWUP); 
       ObjectSet("UpSymbolBz"+i, OBJPROP_WIDTH,2);       
       ObjectSet("UpSymbolBz"+i, OBJPROP_COLOR,White);
       ObjectSet("UpSymbolBz"+i, OBJPROP_ANCHOR, ANCHOR_TOP);        
       
   }   


Here is the cheating, I had to do, to get the text above and below the arrows.

   double vM = (vH + 0.0006);
   double vN = (vL - 0.0006);


Here's the screen shot.


 

As I stated before, "ObjectSetText()" can set several properties at a time, such as Font, Colour and also the text (thus saving you a few lines):

ObjectSetText("UpSymbolBy"+i,texB,0,"Tahoma",Red);
Reason: