OBJPROP_XDISTANCE | 102 | int | Integer value to set/get anchor X distance object property in pixels (see note) |
OBJPROP_YDISTANCE | 103 | int | Integer value is to set/get anchor Y distance object property in pixels (see note) |
OBJPROP_PRICE | Price coordinate | double modifier=number of anchor point |
Use ObjectSetInteger and ObjectSetDouble to change those values.
https://docs.mql4.com/objects/objectsetinteger
Also you can use chart width property to find the right coordination.
- docs.mql4.com
OBJPROP_XDISTANCE | 102 | int | Integer value to set/get anchor X distance object property in pixels (see note) |
OBJPROP_YDISTANCE | 103 | int | Integer value is to set/get anchor Y distance object property in pixels (see note) |
OBJPROP_PRICE | Price coordinate | double modifier=number of anchor point |
Use ObjectSetInteger and ObjectSetDouble to change those values.
https://docs.mql4.com/objects/objectsetinteger
Also you can use chart width property to find the right coordination.
Thanks Yashar
I have even tried that and it doesn't work. I modified the code below but the text doesn't move from its position.
//Create a horizontal line on a chart void drawDashedHorizontalLine(string id, double price, color clr, bool displayLineName=false) { ENUM_LINE_STYLE style = STYLE_DASHDOT; ObjectCreate(id, OBJ_HLINE, 0, timeCurrent, price); ObjectMove(id, 0, timeCurrent, price); ObjectSetInteger(0, id, OBJPROP_STYLE, style); // Line style ObjectSetInteger(0, id, OBJPROP_COLOR, clr); // Line color if (displayLineName) { int height = ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0); int width = ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0); ObjectSetString(0, id, OBJPROP_TEXT, id); ObjectSetDouble(0, id, OBJPROP_PRICE, price); ObjectSetInteger(0, id, OBJPROP_XDISTANCE, width - 1000); ObjectSetInteger(0, id, OBJPROP_YDISTANCE, height); } }Thanks
ObjectCreate("HLINE", OBJ_HLINE, 0, TimeCurrent(), Bid); ObjectCreate("TEXT1", OBJ_TEXT, 0, TimeCurrent(), Bid); double price = ObjectGetDouble(ChartID(),"HLINE",OBJPROP_PRICE); datetime date = ObjectGetInteger(ChartID(),"HLINE",OBJPROP_TIME); ObjectSetInteger(ChartID(), "TEXT1", OBJPROP_TIME, date); ObjectSetDouble(ChartID(), "TEXT1", OBJPROP_PRICE, price);
ObjectCreate("HLINE", OBJ_HLINE, 0, TimeCurrent(), Bid ); ObjectCreate("TEXT1", OBJ_LABEL, 0, 0, 0); datetime time = ObjectGetInteger(ChartID(),"HLINE",OBJPROP_TIME); double price = ObjectGetDouble(ChartID(),"HLINE",OBJPROP_PRICE); int chart_width = ChartGetInteger(ChartID(), CHART_WIDTH_IN_PIXELS, 0); ObjectSetInteger(ChartID(), "TEXT1", OBJPROP_XDISTANCE, chart_width-50); int x=0; int y=0; ChartTimePriceToXY(ChartID(), 0, time, price, x, y); ObjectSetInteger(ChartID(), "TEXT1", OBJPROP_YDISTANCE, y);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
I have a function in MLQ4 to create a horizontal line and I am adding in a Text to the line. However, I want this to be moved to the right side of the chart (attached).
I have tried setting up the anchor and alignment but none of these work as the text is being formed with the HLINE Object not seperatly.
Any help would be much appriciated
Cheers