How to draw a horizontal line?

Hello everybody,
i’m developing a new custom indicator, i haven’t found tutorial about charts drawing.
I have to write an horizontal line with a label above, could give my an example?

Thank you very much!

Hi & welcome to babypips.

Are you using MT4?

:slight_smile:

Yes mt4. Could you give me an example with metaquotes language 4
[ol]
[/ol]

There are 2 ways to draw a horizontal line. One way will put a line at a particular price across the whole chart, the other will start from a particular price [B]and[/B] time, and carry forward.

This example is the former…

ObjectCreate("HLine", OBJ_HLINE , 0,Time[0], Close[0]);
           ObjectSet("HLine", OBJPROP_STYLE, STYLE_SOLID);
           ObjectSet("HLine", OBJPROP_COLOR, Red);
           ObjectSet("HLine", OBJPROP_WIDTH, 0);


This will draw a thin solid red horizontal line named HLine at the current price across the whole chart.

Thank you really really much!

Last question…
How to write a label above the horizontal line?

Thank you, this is a really helpfull forum

This code will create a text object named “HLineText” that contains and displays the words “Some Text” in Arial font size 10 and color red, at the current time & price on the chart.

 
ObjectCreate("HLineText", OBJ_TEXT, 0, Time[0], Close[0];
ObjectSetText("HLineText", "Some Text", 10, "Arial", Red);

If you use the same price for both the line and the text objects, they will overlap, so you need to add/subtract a bit of price to get the text above/below the line.

Also, when you are in MetaEditor, you can highlight a word, like… ObjectCreate… and when you press F1, it will display more reference on it.

:slight_smile:

Perfect!!
Thank you so much

i dont know anything about metaeditor … can u please explain in detail how to add the above codes…

and i want to draw a line starting from the current price and not the whole chart …

Hi itsrijo…that’s asking a bit much…lol…cause it sounds more like you don’t know anything about mql/programming, not just metaeditor which is really just a custom text editor. :wink:

What does the “current” price represent?..it changes every tick. Maybe if you explain in a bit more detail I might already have an indicator that you could use?

You use MT4 ?

You click on ‘Insert’, there plenty object to insert for there. So, you chose one and you insert where you want in the chart.

If it is automatically that you want something, you will need to learn how to insert or activate an indicator.

But actually what do you want to do ? Do you have a system ? an idea ?

[B]Sweet Pip [/B] you are a girl or a guy ???

please tell me

How to draw horizontal line on particular price

and

put particular text on horizontal line…