Download MetaTrader 5
To add comments, please log in or register
Hundreds of articles will help you to create a trading robot. Come and read them!
rod178
276
rod178 2015.01.11 14:28 

Has anyone a code snippet to share that can pull the current  time of a city from some available server (whatever that may be) , including dst if applicable.

 

This information is obviously available from many servers eg  http://www.timeanddate.com/clocks/free.html       http://www.timeanddate.com/services/api/     the issue is  the most effectice method of extracting the data and importing into MT4. 

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.01.11 14:37  
Maybe you show us first and usually others might improve it. If it is not that hard.
rod178
276
rod178 2015.01.11 14:45  
deysmacro:
Maybe you show us first and usually others might improve it. If it is not that hard.

 

 

 

API call to server 

 

    http://api.timezonedb.com/?zone=Australia/Melbourne&key=<Your_API_Key>

<?xml version="1.0" encoding="UTF-8"?>
<result>
    <status>OK</status>
    <message></message>
    <countryCode>AU</countryCode>
    <zoneName>Australia/Melbourne</zoneName>
    <abbreviation>EST</abbreviation>
    <gmtOffset>39600</gmtOffset>
    <dst>1</dst>
    <timestamp>1321217345</timestamp>

</result> 

 

Question" best approach to make the call from within MT4 and import the data 

rod178
276
rod178 2015.01.11 15:20  
rod178:

 

 

 

API call to server 

 

    http://api.timezonedb.com/?zone=Australia/Melbourne&key=<Your_API_Key>

<?xml version="1.0" encoding="UTF-8"?>
<result>
    <status>OK</status>
    <message></message>
    <countryCode>AU</countryCode>
    <zoneName>Australia/Melbourne</zoneName>
    <abbreviation>EST</abbreviation>
    <gmtOffset>39600</gmtOffset>
    <dst>1</dst>
    <timestamp>1321217345</timestamp>

</result> 

 

Question" best approach to make the call from within MT4 and import the data 

 

Using JavaScript Object Notation via  browser

 http://api.timezonedb.com/?zone=Australia/Perth&format=json&key= myAPIkey

=>  {"status":"OK","message":"","countryCode":"AU","zoneName":"Australia\/Perth","abbreviation":"AWST","gmtOffset":"28800","dst":"0","timestamp":1421017908}

OR

 http://api.timezonedb.com/?zone=Europe/London&format=json&key=myAPIkey

=>  {"status":"OK","message":"","countryCode":"GB","zoneName":"Europe\/London","abbreviation":"GMT","gmtOffset":"0","dst":"0","timestamp":1420989442} 

OR (this time note dst)

http://api.timezonedb.com/?zone=Australia/Sydney&format=json&key=myAPIkey

 =>  {"status":"OK","message":"","countryCode":"AU","zoneName":"Australia\/Sydney","abbreviation":"AEDT","gmtOffset":"39600","dst":"1","timestamp":1421029111}

 

Some work on a JSON parser link  https://www.mql5.com/en/code/11134

and XML parser    https://www.mql5.com/en/articles/1366   

                          https://www.mql5.com/en/code/1998 

 

 

Question is how to send and import  result into MT4 string variable. 

Is it better to import XML or JSON

/
To add comments, please log in or register