PRICE_HISTORY Command
Gets history data of prices (Open, High, Low, Close) of a specified symbol-period.
Help
Example
Single Line command (necessary for MTsocketAPI):
{"MSG":"PRICE_HISTORY", "SYMBOL":"EURUSD", "TIMEFRAME":"PERIOD_H1", "FROM_DATE":"2023/08/02 07:00:00", "TO_DATE": "2023/08/02 10:00:00"}
Same command in Beauty Format:
{
"MSG":"PRICE_HISTORY",
"SYMBOL":"EURUSD",
"TIMEFRAME":"PERIOD_H1",
"FROM_DATE":"2023/08/01 07:00:00",
"TO_DATE":"2023/08/02 13:00:00"
}
MTsocketAPI reply:
{
"MSG":"PRICE_HISTORY",
"SYMBOL":"EURUSD",
"TIMEFRAME":"PERIOD_H1",
"RATES":[
{
"TIME":"2023.08.02 10:00:00",
"OPEN":1.09800,
"HIGH":1.09801,
"LOW":1.09679,
"CLOSE":1.09784,
"REAL_VOLUME":0,
"TICK_VOLUME":2431,
"SPREAD":0
},
{
"TIME":"2023.08.02 09:00:00",
"OPEN":1.09838,
"HIGH":1.09845,
"LOW":1.09759,
"CLOSE":1.09801,
"REAL_VOLUME":0,
"TICK_VOLUME":2538,
"SPREAD":0
},
{
"TIME":"2023.08.02 08:00:00",
"OPEN":1.09901,
"HIGH":1.09923,
"LOW":1.09756,
"CLOSE":1.09839,
"REAL_VOLUME":0,
"TICK_VOLUME":3722,
"SPREAD":0
},
{
"TIME":"2023.08.02 07:00:00",
"OPEN":1.09896,
"HIGH":1.09969,
"LOW":1.09815,
"CLOSE":1.09896,
"REAL_VOLUME":0,
"TICK_VOLUME":3872,
"SPREAD":0
}
],
"ERROR_ID":0,
"ERROR_DESCRIPTION":"no error",
"DEMO":"MTsocketAPI running in DEMO mode (www.mtsocketapi.com)"
}
Important
Be careful with this command. If you retrieve millions of rows from MT4 the performance may worsen visibly while processing a big amount of data.
Important
If you haven't downloaded that symbol/timeframe data before, MT4 does not yet have the data downloaded. Then it will return an error and it will start download it. You must ask for the data again until you don't receive any error.