Is There A Way to Determine First Visible Bar?

How to create strategies and indicators
Message
Author
camster_7
Posts: 2
Joined: Tue Sep 16, 2014 5:53 pm

Is There A Way to Determine First Visible Bar?

#1 Postby camster_7 » Tue Sep 16, 2014 6:07 pm

MT4 provides a WindowFirstVisibleBar() function for determining the shift value for the left most bar that is visible on the current chart. I reviewed the IndicatorInferaceUnit.h and I am not seeing an equivalent function for this. So in the absence of not having a API command for obtaining this shift value, does anyone know of a way this could be done programically?

One idea I had was to create a Text Label and position it a left hand side of screen and check the Screen Coordinates checkbox so that it does not move. Then using an indicator issue an ObjectGet command to obtain the OBJPROP_TIME1 value. Unfortunately this did not return a time and instead return the X coordinate integer value. So my next school of thought was to modify my indicator code to set the OBJPROP_SCREENCOORDS property of this Text Label to Zero, then issue same ObjectGet command thinking that this would give me the proper time. Unfortunately this did not do so and instead gave me the same X coordinate integer value.

Any ideas how this could be accomplished?

User avatar
neHcioHep
Posts: 18
Joined: Sat Nov 21, 2009 5:49 pm
Contact:

Re: Is There A Way to Determine First Visible Bar?

#2 Postby neHcioHep » Wed Sep 17, 2014 1:08 pm

Hello camster you should try something like this:

Code: Select all

var ChartInfo: TChartInfo;
...

if GetChartInfo(ChartInfo) then
     Print('First index = ' + inttostr(ChartInfo.FirstIndex));


camster_7
Posts: 2
Joined: Tue Sep 16, 2014 5:53 pm

Re: Is There A Way to Determine First Visible Bar?

#3 Postby camster_7 » Thu Sep 18, 2014 1:00 pm

neHcioHep, thank you very much for your suggestion! works like a charm!


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 20 guests