Download MetaTrader 5

How to navigate/move the chart to an created object or datetime

To add comments, please log in or register
Use MQL5 Cloud Network. It is secure!
Nikolay 2016.04.09 20:46 

Few questions about chart navigation with MQL (programming, not UI use):

1) How can I navigate/move/focus the chart to an existing object If I know the object name? (in a similar way when I click show in the objects list)

2) How can I navigate/move/focus the chart to a specified datetime?

whroeder1 2016.04.10 01:36  
Perhaps you should read the manual (Edited by moderator). ChartNavigate - Chart Operations - MQL4 Reference
Fernando Carreiro
Fernando Carreiro 2016.04.10 03:48  
  1. Use the "ObjectFind()" to get a specified named object and then use "ObjectGetTimeByValue()" to get its date/time.
  2. Get the Charts Symbol and Period with the functions "ChartSymbol()" and "ChartPeriod()".
  3. With the date and time (from step 1), find the bar shift with the "iBarShift()" function for the specified symbol and period obtained in the step 2.
  4. Disable the auto scrolling of the chart with the "ChartSetInteger()" function and the CHART_AUTOSCROLL property with a value of "0" equivalent to "false".
  5. Obtain the chart's current bar positioning, using the "ChartGetInteger()" function and the properties CHART_FIRST_VISIBLE_BAR and CHART_VISIBLE_BARS.
  6. Calculate the required bar positioning offset and then use the function "ChartNavigate()" to position the chart according to your requirements.
Nikolay 2016.04.10 13:30  

Thank you a lot FMIC!

Such step by step description was exaclty what I was looking for! Thank you!

To add comments, please log in or register