3.2.3Time zones for candle requests

Like all times in the framework, candle ts values are UTC. However, candle timestamps are more complicated than that.

For timeframes above H1, you can set a timezone value defining how you want candles to be aggregated.

For example, rather than requesting daily candles based on UTC days, you can instead say that you want aggregation based on UTC+2. This is extremely common in forex because the markets open at 5pm New York time on Sunday. If you request candles based on UTC, there are then six D1 candles per week, not five: candles for Monday to Friday, plus a stub of candle covering the period from 9pm/10pm UTC (5pm in New York) to midnight on Sunday.

Let's say that you request D1 candles aggregated based on UTC+2 (as illustrated below). Each daily candle will cover 24 hours. But its start time will not be midnight UTC. The ts value of each candle will represent 10pm (or 9pm during periods of daylight savings).

You can specify aggregation in your candle request using a timezone object (see also time conversion). This has two properties:

Property

Type

Description

offset

Integer (number of minutes)

Base offset in minutes from UTC, e.g. 120 or -300. Note: although this offset lets you specify a number of minutes, all existing back-end platforms require that any offset for candle requests is a number of hours. Therefore, offset should be a multiple of 60.

dstMode

FXB.DSTModes

Daylight savings mode. One of the values of the FXB.DSTModes enumeration: NONE, USA, EUROPE, AUSTRALIA

For example, the most common request for forex analysis looks like this:

Framework.RequestCandles({

instrumentId: "EUR/USD",

timeframe: 86400, // D1,

timezone: {

// 2 hours ahead of UTC, with USA daylight savings.

// Therefore, constant 7 hours ahead of New York time.

// Market open at 17:00 NYC on Sunday is reported as a candle ts of 00:00

offset: 120,

dstMode: FXB.DSTModes.USA

}

}, function (MsgCandles) {

});

This requests aggregation based on UTC+2, changing to UTC+3 on the USA daylight savings schedule. In effect, candles are aggregated based on a day running from 5pm-5pm New York time.

The further and very important thing to note is that the user can set a preference in the MyTrader platform for how candle data should be aggregated. If you do not explicitly set a timezone in your candle request, you will automatically get the user's preferred settings. And the default settings in MyTrader are not UTC; they're UTC+2 with USA daylight savings.

In other words: if you do not set your own timezone in your candle request, what you will get is aggregation based on UTC+2/3, unless the user has changed the standard settings in the MyTrader platform. Daily candles will have a ts at 9pm or 10pm UTC, not midnight UTC.

However, in your request you can also optionally specify convertTimes:true. If set, this automatically converts all the candles ts values before returning the data to you (using Framework.AdjustUTCToZone).