GLYTioNyMUSkINtOldEs: How do I get get X and Y value to determine chart position for HLine.
- You don't. A Hline has no time. You created it with a zero time (1970.) That is what you read back.
-
ChartTimePriceToXY(0,0,DOT_T,DOT_P,x,y)
Since DOT_T will always be zero, why do you think you can ever get an x coordinate?
DOT_T is not 0
DOT_T has a value of 1970 xxxxxxxxx
What is the workaround?
DOT_T is 0.
ObjectCreate("Entry", OBJ_HLINE, 0, 0, Ask);
datetime 0 is 1 January, 1970.
There is no workaround.
Why would you need the x co-ordinate of a horizontal line?
I have deleted your new topic as it is related to this one.
Do not open multiple topics with the same subject.
They are the same, EXACT, value. Online Conversion - Unix time conversion
ChartRedraw(0); ObjectGetDouble(0,"Entry",OBJPROP_PRICE,0);
Is it possible just to get the y co-ordinate of HLine? Maybe there's a function I am not aware of.
I want to create a label that moves with the Hline.
So you only need the Y co-ordinate
ObjectCreate("Entry", OBJ_HLINE, 0, 0, Ask); ObjectSet("Entry", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("Entry", OBJPROP_COLOR, clrGreen); double DOT_P = ObjectGetDouble( 0,"Entry",OBJPROP_PRICE ); datetime DOT_T =TimeCurrent() ; int x,y; if(!ChartTimePriceToXY(0,0,DOT_T,DOT_P,x,y)) Print("Error ",GetLastError()); else Print ("X=",x," Y=",y);
You must move it. In chart event, if the Hline is dragged, get its price and move your label.
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - I see your code. It uses getXY, which you already know will not work for hlines, because you have no time.
- I see your code. It uses getInteger(prop time), which you already know will not work for hlines, because they have no time.
- Stop pasting the same code everywhere and start thinking. If you don't have time from hlines, what can you use to get the Y from getXY
So you only need the Y co-ordinate
still didn't work, the label doesn't move with the Hline when I drag it,
The code that I posted was to enable you to get the Y co-ordinate.
Thanks,
I have input current time into the HLine so that I can get the Y co-ordinate later from ChartTimePriceToXY.
Now, the problem is, if I were right click on the HLine and change the price level, the label will move with the HLine.
If I were to drag the HLine, the x and y obtained from the HLine is 0,0. I don't understand why, because I have cater for OnChartEvent; even clicking on the chart doesn't change a thing (x and y obtained from a dragged-HLine is still 0,0)
I have already given you the solution but you have chosen to ignore it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Solution by Keith Watford
*Input current date/time into ChartTimePriceToXY