Time zone handling

Original (English)

Zorro's standard time zone is UTC (Greenwich mean time), which is also the time zone of historical data, logs, and charts. Time and date functions and variables are normally also based on UTC time. Alternatively, local time zones can be used either on the bar or on the asset level. For handling or converting time zones, the following variables are available:


BarZone

Time zone of bars (default: UTC). Affects bar generation: daily bars will start and end at BarZone midnight plus BarOffset. For this, set BarZone before the first asset call. BarZone is also used by several date/time functions that use local time. For using specific asset-dependent time zones with intraday bars, see AssetFrameZone and AssetMarketZone.

HistoryZone

Time zone of the historical data files, for converting them to UTC. This variable is rarely needed since timestamps in historical data files should be already in UTC. If not, set HistoryZone to the time zone in the data. The time stamps in historical data files and dataset files are then automatically converted to UTC on dataLoad or dataParse.

BrokerZone

Time zone of the broker plugin. This variable is rarely needed since broker plugins normally return timestamps in UTC. Otherwise the broker plugin is supposed to set BrokerZone with the GET_BROKERZONE command. The broker API time stamps are then converted to UTC on import.

LogZone

Time zone of the log and chart. If not set, all dates and times in the log and chart are in UTC.

AssetMarketZone

Time zone of the current asset; initially read from the Market field of the asset list, otherwise copied from BarZone or set by script.

AssetFrameZone

Time zone of the current asset for daily trading; used to set AssetFrame to a daily TimeFrame that begins at FrameOffset in local time.

Type:

int, UTC for UTC time (default), EST for New York, WET for London, CET for Frankfurt, AEST for Sydney, JST for Tokyo, or any number from -23..+23 that gives the time zone offset in hours to UTC. Daylight saving time is used, except for UTC and for time zones at or beyond JST.

AssetFrame

Asset specific time frame, automatically set by AssetFrameZone. 0 when the current asset had no price quotes in the current bar or when its market is closed; negative number of skipped bars when the market opens; 1 otherwise. Normally used to set TimeFrame = AssetFrame for skipping bars outside market hours, or for trading on different time zones (see example).

Type:

int, read/only

Remarks:

  • BarZone, HistoryZone, and BrokerZone affect the sampling of bars and thus must be set before loading history with the first asset() call. The asset-specific AssetZone and AssetMarket must be set after selecting the asset and can be changed at runtime.
  • If backtests use price history in local time and no time zone is set, all time/date functions and variables are then also in local time instead of UTC.
  • Setting a non-UTC BarZone generates a daily bar of 23 or 25 hours when the daylight saving period begins or ends. The run function can run twice or be skipped when the clock is set backwards or forwards. This should be taken into account in strategies that strongly rely on a 24-hour bar period or on bars ending or starting at a certain time.
  • For emulating day bars of different assets with different time zones, use 1-hour bars with AssetFrameZone and AssetFrame (see example). Use FrameOffset for starting the emulated bar at a certain local hour.

Examples:

// trade daily at 15:30 New York time
    BarPeriod = 1440;
    BarOffset = 15*60+30;
    BarZone = EST;
    ...
    
    // trade two assets on different time zones
    BarPeriod = 60;
    FrameOffset = 10; // trade both assets at 10:00 am local time
    while(asset(loop("EUR/USD","USD/JPY")))
    {
      if(strstr(Asset,"EUR"))
        AssetFrameZone = WET;
      else if(strstr(Asset,"JPY"))
        AssetFrameZone = JST;
      TimeFrame = AssetFrame; // use a daily time frame changing at 10:00 local time
      ...
    }

See also:

TimeFrame, StartMarket, BarMode, Time/Date functions, asset

 

► latest version online

Übersetzung (Deutsch)

Zorros Standard-Zeitzone ist UTC (Greenwich Mean Time), die auch die Zeitzone für historische Daten, Logs und Diagramme ist. Zeit- und Datumsfunktionen und Variablen basieren normalerweise ebenfalls auf UTC-Zeit. Alternativ können lokale Zeitzonen entweder auf der Balken- oder auf der Asset-Ebene verwendet werden. Für die Handhabung oder Umrechnung von Zeitzonen stehen die folgenden Variablen zur Verfügung:


BarZone

Zeitzone der Balken (Standard: UTC). Beeinflusst die Balkenerstellung: Tägliche Balken beginnen und enden um Mitternacht der BarZone plus BarOffset. Dafür setzen Sie BarZone vor dem ersten asset Aufruf. BarZone wird auch von mehreren Datum/Zeit-Funktionen verwendet, die lokale Zeit nutzen. Für die Verwendung spezifischer, assetabhängiger Zeitzonen bei Intraday-Balken siehe AssetFrameZone und AssetMarketZone.

HistoryZone

Zeitzone der historischen Datendateien, zur Umrechnung in UTC. Diese Variable wird selten benötigt, da Zeitstempel in historischen Datendateien bereits in UTC sein sollten. Wenn nicht, setzen Sie HistoryZone auf die Zeitzone der Daten. Die Zeitstempel in historischen Datendateien und Dataset-Dateien werden dann automatisch bei dataLoad oder dataParse in UTC umgerechnet.

BrokerZone

Zeitzone des Broker-Plugins. Diese Variable wird selten benötigt, da Broker-Plugins normalerweise Zeitstempel in UTC zurückgeben. Andernfalls soll das Broker-Plugin BrokerZone mit dem GET_BROKERZONE Befehl setzen. Die Broker-API-Zeitstempel werden dann beim Import in UTC umgerechnet.

LogZone

Zeitzone des Logs und des Diagramms. Wenn nicht gesetzt, sind alle Daten und Zeiten im Log und Diagramm in UTC.

AssetMarketZone

Zeitzone des aktuellen Assets; zunächst aus dem Market Feld der Asset-Liste gelesen, andernfalls von BarZone kopiert oder durch das Skript gesetzt.

AssetFrameZone

Zeitzone des aktuellen Assets für den täglichen Handel; verwendet, um AssetFrame auf ein tägliches TimeFrame zu setzen, das um FrameOffset in lokaler Zeit beginnt.

Typ:

int, UTC für UTC-Zeit (Standard), EST für New York, WET für London, CET für Frankfurt, AEST für Sydney, JST für Tokio oder jede Zahl von -23..+23, die den Zeitzonenoffset in Stunden zu UTC angibt. Die Sommerzeit wird verwendet, außer für UTC und für Zeitzonen an oder über JST.

AssetFrame

Asset-spezifischer Zeitrahmen, automatisch gesetzt durch AssetFrameZone. 0, wenn das aktuelle Asset keine Preisangebote im aktuellen Balken hatte oder wenn sein Markt geschlossen ist; negative Anzahl übersprungener Balken beim Öffnen des Marktes; 1 ansonsten. Normalerweise verwendet, um TimeFrame = AssetFrame zu setzen, um Balken außerhalb der Marktzeiten zu überspringen oder für den Handel in verschiedenen Zeitzonen (siehe Beispiel).

Typ:

int, nur lesbar

Anmerkungen:

  • BarZone, HistoryZone und BrokerZone beeinflussen die Abtastung von Balken und müssen daher vor dem Laden der Historie mit dem ersten asset() Aufruf gesetzt werden. Die asset-spezifischen AssetZone und AssetMarket müssen nach der Auswahl des Assets gesetzt werden und können zur Laufzeit geändert werden.
  • Wenn Backtests Preisverläufe in lokaler Zeit verwenden und keine Zeitzone gesetzt ist, sind alle Zeit-/Datumsfunktionen und Variablen ebenfalls in lokaler Zeit statt in UTC.
  • Das Setzen einer nicht-UTC BarZone generiert einen täglichen Balken von 23 oder 25 Stunden, wenn die Sommerzeitperiode beginnt oder endet. Die run Funktion kann zweimal ausgeführt werden oder übersprungen werden, wenn die Uhr zurück- oder vorgedreht wird. Dies sollte in Strategien berücksichtigt werden, die stark auf einen 24-Stunden-Balkenzeitraum oder Balken, die zu einer bestimmten Zeit enden oder beginnen, angewiesen sind.
  • Zum Emulieren von Tagesbalken verschiedener Assets mit unterschiedlichen Zeitzonen, verwenden Sie 1-Stunden-Balken mit AssetFrameZone und AssetFrame (siehe Beispiel). Verwenden Sie FrameOffset, um den emulierten Balken zu einer bestimmten lokalen Stunde zu starten.

Examples:

// trade daily at 15:30 New York time
    BarPeriod = 1440;
    BarOffset = 15*60+30;
    BarZone = EST;
    ...
    
    // trade two assets on different time zones
    BarPeriod = 60;
    FrameOffset = 10; // trade both assets at 10:00 am local time
    while(asset(loop("EUR/USD","USD/JPY")))
    {
      if(strstr(Asset,"EUR"))
        AssetFrameZone = WET;
      else if(strstr(Asset,"JPY"))
        AssetFrameZone = JST;
      TimeFrame = AssetFrame; // use a daily time frame changing at 10:00 local time
      ...
    }

See also:

TimeFrame, StartMarket, BarMode, Time/Date functions, asset

 

► latest version online

Siehe auch:

asset, setf, resf

 

► Neueste Version online