Label on H_Line

 

i am trying to add a label to my H_Line 

I have tried OBJPROP_NAME AND OBJ_LABEL, but nothing is quite working correctly.


 if(TriggerLineTrade=="CA")    {ObjectSet( objNameDes, OBJPROP_COLOR, clrOrange );
        ObjectSetString(0,objNameDes,OBJPROP_NAME,"Close All");}  

or i tried OBJ_LABEL

I want the word "Close All" to show on the top of the Horizontal line or drawn line  on the Right.


I also tried Drawlable, but still got something wrong.  Not showing up

void drawLabel(string objNameDes,double lvl,color Color)
{
    if(ObjectFind(objNameDes) != 0)
    {
        ObjectCreate(objNameDes, OBJ_TEXT, 0, Time[10], lvl);
        ObjectSetText(objNameDes, objNameDes, 10, "Arial", EMPTY);
        ObjectSet(objNameDes, OBJPROP_COLOR, Color);
    }



drawLabel("Close All",objNameDes,Magenta);

any guidance would be greatly appreciated.

 

These samples are copied from programs I actually use.

if (ObjectFind(obj_name) < 0)
{
   ObjectCreate(obj_name, OBJ_HLINE, 0, time[1], price);
   ObjectSet(obj_name, OBJPROP_STYLE, Line_Style);
   ObjectSet(obj_name, OBJPROP_WIDTH, Line_Width);
   ObjectSet(obj_name, OBJPROP_COLOR, Line_Color);
   ObjectSet(obj_name, OBJPROP_BACK,  true);
   ObjectSetString(0, obj_name, OBJPROP_TEXT, DoubleToStr(price, Digits - 2));
}

1

You need to check the "Show object description" checkbox in the settings panel to show this.

3

if (ObjectFind(objname) < 0)
{
   dText = "  " + text + "  " + DoubleToString(value, 4);
   ObjectCreate(objname, OBJ_TEXT, index, Time[0], value);
   ObjectSetText(objname, dText, TxtSize, font, col);
}

2

 
Nagisa Unada:

These samples are copied from programs I actually use.


You need to check the "Show object description" checkbox in the settings panel to show this.



thanks.   I will try that and get back to you.


Is there anyway you can make the text to show on the right side and not the left (Show description)?

 
Kristina Suh:

Is there anyway you can make the text to show on the right side and not the left (Show description)?

You probably can't do that with the first method.

In the second method, the line and OBJ_TEXT are separate, so you can freely adjust the position.

 

thanks,


I also would like to delete the line when hit.

ObjectSetText( objName, "Remove", 10 ); 
         remove = ObjectDescription(objName);
         DeleteLines();



void DeleteLines()
            {
               
               Print("Remove "+remove);
               if(ObjectDescription(remove) == OBJ_HLINE || ObjectDescription(remove) == OBJ_VLINE) ObjectDelete(remove);
              
            }

but it doesn't delete the lines


I want to delete only the lines that have Remove in the description.  

Or if I can change the obj name to remove and then delete obj with Remove in the name..

 

What the hell is this? You don't know how to open a reference?

Select "ObjectDelete" and press "F1". Then the reference will open and you should see the following

bool ObjectDelete( 
   string object_name // object name 
   );


 
Nagisa Unada:

What the hell is this? You don't know how to open a reference?

Select "ObjectDelete" and press "F1". Then the reference will open and you should see the following



Wow.  that was a bit rude..

What makes you think I don't know how to use reference?

I have tried everything and I am only stuck on one thing, everything else works fine. 

If you can't help, pls don't respond.

 
Kristina Suh:

Wow.  that was a bit rude..

What makes you think I don't know how to use reference?

I have tried everything and I am only stuck on one thing, everything else works fine. 

If you can't help, pls don't respond.

Nagisa did help.

Read the documentation.

 
Keith Watford:

Nagisa did help.

Read the documentation.

Wow..  seriously,  I thought this was a forum to help people.


I have been reading and researching many hours of documentation and managed to get 99% of what I wanted working, but I was just stuck with deleting an object with a specific description.

The documentation is very limited on examples, so sometimes it is hard to decipher what is the correct coding.

replying with "What the hell is this? You don't know how to open a reference?"

is not helping, but just rude.  


All in all.   I have figured it out myself..   Thanks for your help.

 

I don't understand the subtle nuances, because I'm using a translation tool.

I just wanted to say why you wrote such a nonsensical program when you could have written it with a single line of "ObjectDelete(object_name);" if you had checked the reference properly.