MQL4 - automated forex trading   /  

Forum

Converting time / price to pixel coordinates on objects

Back to topics list To post a new topic, please log in or register

avatar
26
adamp 2010.03.18 21:49 
I need someones help, because I am stuck since a few hours now with the following task:

A graphical object is attached to a chart - an arrow in this case. This object needs a time and a price as coordinate.
Now I wanna convert the time and price coordinate into a pixel based coordinate. Any idea how this can be achieved?

I was thinking about using WindowPriceMin / Max, WindowsFirstVisibleBar and WindowBarsPerChart, but don't know exactly how.
To help me with this problem, I also have written a DLL that gives me the width and height of the current chart window in pixels.

But still no idea how to solve it... maybe sitting too long in front of this. Any help appreciated :-)
Error 146 ("Trade context busy") and How to Deal with It

Error 146 ("Trade context busy") and How to Deal with It

The article deals with conflict-free trading of several experts on one МТ 4 Client Terminal. It will be useful for those who have basic command of working with the terminal and programming in MQL 4.


avatar
3265
Ais 2010.03.18 22:57 

avatar
26
adamp 2010.03.19 00:06 
Thank you for providing this link, but I can's see how to use this code. Can you give an example?

avatar
75
nondisclosure 2010.03.19 04:22 
adamp wrote >>
I need someones help, because I am stuck since a few hours now with the following task:

A graphical object is attached to a chart - an arrow in this case. This object needs a time and a price as coordinate.
Now I wanna convert the time and price coordinate into a pixel based coordinate. Any idea how this can be achieved?

I was thinking about using WindowPriceMin / Max, WindowsFirstVisibleBar and WindowBarsPerChart, but don't know exactly how.
To help me with this problem, I also have written a DLL that gives me the width and height of the current chart window in pixels.

But still no idea how to solve it... maybe sitting too long in front of this. Any help appreciated :-)


"I also have written a DLL that gives me the width and height of the current chart window in pixels."

Really? Can you post the code in your DLL that got the width and height of the current chart in pixels? I've been trying to figure this EXACT problem out. I may be able to solve it if I can see how you got the chart size in pixels.


avatar
75
nondisclosure 2010.03.19 04:25 
Ais wrote >>

A Sample: Chart metrics, http://forum.mql4.com/17243/page7#276861


Won't work. price/time isn't a 1:1 ratio (no matter how you divide it). Now, if your chart windows was a perfect square, that would work beautifully.

avatar
26
adamp 2010.03.19 05:19 
This library already helped me a lot. Now I know how many bars are left on the right hand side of the chart shift.
Together with the bars on the left, min and max price, I can calculate a good approximation of the position.

I am very excited how accurate this will be. But seems promising so far.

avatar
75
nondisclosure 2010.03.19 20:19 
adamp wrote >>
This library already helped me a lot. Now I know how many bars are left on the right hand side of the chart shift.
Together with the bars on the left, min and max price, I can calculate a good approximation of the position.

I am very excited how accurate this will be. But seems promising so far.


Well, I found where to ge the height: http://codebase.mql4.com/5984
Back to topics list  

To add comments, please log in or register