Issues with Time[] and drawing graphics on bars?

 

Hi Guys,

 I'm trying to make an EA with an indicator that draws text on particular bars of interest from the chart window.

 I'm having issues with finding the appropriate X and Y coordinates for visible bars.

 

I have discovered the number of bars on chart and the first visible bar using WindowBarsPerChart() and WindowFirstVisibleBar() respectively, which successfully represent the current number of visible bars and the index for the first visible bar.

 

I read in another thread that to get the relevant X and Y coordinates, it is easy, because for instance, the X coordinate of a bar is representative of its time. Thus, time[0] (or time[1] maybe) should represent the X location of the bar. However i do not think it is representing it with respect to its position --graphically-- as Time[0].

 For instance, if i set the chart to H1 timescale, and zoom in fully, WindowBarsPerChart() returns 15. Which is reasonable if you count the bars. However Time[0] returns 1292490000. Obviously not a pixel position as the window is no more than 1000 pixels wide!

 My questions are:

a)  Do i need to take the Time[] values and divide them by some divisor to 'scale' it to pixels?

b) Or am I using the wrong method to obtain the pixel positions? ie Time[] is not the best thing to use.  

 

Thanks,

Seb 

 
seravitae:

b) Or am I using the wrong method to obtain the pixel positions? ie Time[] is not the best thing to use.

Time[] as nothing to do with the pixel positions c Time[]
 

Hi gjol,

 yes, i see this now, which means that some other forum post i read was wrong.

To be more specific, I am trying to create a one dimensional array called barXLocation which has a length WindowBarsPerChart(), and where each element indicates the graphical X position (centered) of each bar on the visible chart. I cannot seem to find anything in the documentation about what variables/functions I can use to grab the graphical location data.

 I have found a script that uses some trickery to work out the window height in pixels, however I see no functions for determining the width of the window - the height is determined via WindowPriceMin() and WindowPriceMax(), but there isnt an equivilant for the X dimension, which is what i require.

 

i think the only way to do that is using WIN API (i'm not sure)

 

Its okay - I discovered the use of "arrows" - this does exactly what I want.. Places a marker on the center of the bar, and scrolling/rescaling works perfectly. Its not as fancy as what I wanted but it will do.

Is there anything similar to "arrow" (where i can specify X/Y via Time[n] and High[n]) except for like, text or something? 

Reason: