Time/date periods

Original (English)

Time/date periods

StartDate

Start of the simulation; determines the begin of the backtest or of the preceding training period. The variable can be set in different ways:
- A 4-digit year number (f.i. 2006) gives the number of the historical data file with which the simulation begins (f.i. EURUSD_2006.t6). If the data file has no year number (f.i. MSFT.t6), the simulation starts with the earliest record in the file that matches the year number.
- A date in yyyymmdd format starts the simulation at a certain date (f.i. 20090401 = April 1st, 2009). The LookBack period is added in front of the date and begins accordingly earlier. Due to the lookback period, StartDate = 2006 is not the same as StartDate = 20060101.
- StartDate = NOW sets the start date to the current day, and executes the run function in [Trade] mode immediately after the lookback period, regardless of the current time. Useful for strategies that do not run permanently, but are only started for modifying a portfolio.
- StartDate = 0 (default) starts the simulation with NumYears before the current year.

EndDate

End of the simulation, either 4 digits for determining the number of the last historical price data file (similar to StartDate), or a date in yyyymmdd format for ending the backtest at that date (f.i. 20091231 = December 31, 2009), or NOW for the current day. If at 0 (default), the simulation runs until the end of the available price history. In January it runs until the end of the price history of the previous year.

NumYears

Number of years of the simulation if no StartDate or EndDate is given (default: 6 years; max 32 years). The current year counts as one full year. Set NumYears to -1 for not loading any prices by assetHistory.

MaxBars

Maximum number of bars of the simulation (default: 0 = no limit). The simulation ends either at EndDate or after the given number of bars (including the LookBack period), whichever happens earlier.

UpdateDays

Interval in days for automatically downloading price data from the selected broker (default: 0 = don't automatically download price data). The download process starts when calling asset() the first time in a [Test] or [Train] cycle and the price history is older than the given number of days. Zorro will then log in to the broker, download recent price data in M1 or T1 format dependent on History, and add it to the price history. This variable can be used for getting fresh data in a retraining or retesting process. It has no effect in [Trade] mode. Set UpdateDays to -1 for loading prices even when the history is up to date.

ReTrainDays

Interval in days for automatically retraining a live trading system (Zorro S required; default: 0 = no automatic retraining). Set this to the duration of the WFO test period for keeping a WFO trained system in sync with the market when it trades unsupervised for a long time. The retraining interval starts with the session start.

GapDays

Maximum allowed gap in days in the historical prices and in downloaded price data (default: 0 = no gap checking). Set this to 2 or above in order to check the price curve for gaps and inconsistencies, and give an Error 047 message if any are detected. Weekends and Holidays are except from gap checking. Gaps of 1 day are normal in historical prices when market holidays are not set up in the Holidays array (see below).

StartWeek

EndWeek

Start and end of the business week in dhhmm local time in the BarZone, where d = day number (1 = Monday .. 7 = Sunday) hh = hour and mm = minute. Default: Start 72300 (Sunday 23:00), end 52000 (Friday 20:00). Used to determine the weekend for BarMode flags. 

StartMarket

EndMarket

Daily global market opening and closing time in hhmm local time in the BarZone, hh = hour and mm = minute. Default: 0930. Used for local time functions (day, market, etc.) and for trading and sampling of bars, dependent on BarMode. Automatically converted from AssetMarketStart/End (see below) when BR_LOCAL is set. 

AssetMarketStart

AssetMarketEnd

Local market opening and closing time of the selected asset, in hhmm local time in the AssetMarketZone. Initially read from the Market field in the asset list; can also be set by script. Used for intraday trading in BR_LOCAL mode. 

Type:

int

 

Holidays

Pointer to an int array of holiday dates either in yyyymmdd or in mmdd format, ending with 0. Default: { 0101, 1225, 0 }. Can be set to a 0-terminated array for defining local stock market holidays. The yyyymmdd format specifies a holiday only in a certain year, mmdd for all years.

Type:

int*
 

Now

Date/time variable in DATE format for passing a certain point in time to the contractUpdate function or to the NOW argument of date/time functions. When at 0 (default), the current PC date and time is used for NOW.

DayOffset

Time period in DATE format to be added to the current time in [Trade] mode for special purposes, such as a quick test of the live behavior at a particular day, or at weekend or market closure (see also Troubleshooting). Set it to 1 or adding a day, or to 1./24 for adding one hour to the current time, or increase it by 1./24 at any 1-hour bar for trading a system in double speed. Affects also the lookback period and the time of a connected server; does not affect timestamps of historical data.

Type:

var
 

Remarks:

  • The earliest possible StartDate is determined by the availability of historical price data. M1 data back to 2002 can be downloaded from the Zorro website. In 2002 the EUR replaced national currencies, therefore forex backtests before that date make normally not much sense.
  • StartDate and EndDate can be used to 'zoom' the backtest to a certain period and examine the trade behavior of that period in more detail.
  • If the StartDate lies before the history start of the first asset, the simulation oe lookback period begins with the first bar of the historical data. If COMMONSTART is set, the simulation begins with the latest history start of any asset. The simulation ends with the earliest history end of all assets or with EndDate, whichever is earlier.
  • StartWeek, EndWeek, StartMarket, EndMarket, AssetMarketStart, AssetMarketEnd have normally little effect on bar generation, since historical data contains anyway no price ticks during market closure, weekends, or holidays. However they can be used to limit trading time or to determine market hours in combination with BR_FLAT. Note that they are normally not identical to real market open and close times, since they only suppress or enable bars or indicators. For actions precisely on market open or close, use one-minute bars or the tick function. 
  • All variables that affect bar generation, such as StartDate, EndDate, NumYears, Holidays, UpdateDays etc. must be set before loading price data or calling asset the first time.
  • WFO parameters and rules are only valid for the simulation period with which they were created. If the period is changed, the strategy must be trained again. When re-training the last WFO cycle for live trading, set EndDate to 0 or NOW, otherwise the training period would end with EndDate.
  • The initial run of a strategy (INITRUN) has no valid date or time until the the start and end date are set and the first asset is loaded.
  • For simulating a 'fast forward' mode in a live trading test, use a tock function that adds a time period to DayOffset at every minute. For instance, DayOffset += 9./1440 adds 9 minutes per minute, and thus lets time pass 10 times faster.

Example:

StartDate = 20150901; // start the simulation in September 2015
EndDate = 20160901; // and simulate one year
static int USHolidays[10] = { 0101, 0218, 0419, 0704, 0527, 0902, 1128, 1225, 0 };
Holidays = USHolidays; // set up US holidays

See also:

bar, BarPeriod, LookBack, Detrend, time/date functions, PlotDate

 

► latest version online

Übersetzung (Deutsch)

Zeit-/Datumszeiträume

StartDate

Beginn der Simulation; legt den Startpunkt des Backtests oder der vorausgehenden Trainingsphase fest. Die Variable kann auf verschiedene Arten gesetzt werden:
- Eine 4-stellige Jahreszahl (z.B. 2006) gibt die Nummer der Historiendatei an, mit der die Simulation beginnt (z.B. EURUSD_2006.t6). Hat die Historiendatei keine Jahreszahl (z.B. MSFT.t6), startet die Simulation mit dem frühesten Datensatz in der Datei, der zur Jahreszahl passt.
- Ein Datum im yyyymmdd-Format startet die Simulation an einem bestimmten Datum (z.B. 20090401 = 1. April 2009). Die LookBack-Periode wird vor dieses Datum angefügt und beginnt entsprechend früher. Aufgrund der Lookback-Periode ist StartDate = 2006 nicht identisch mit StartDate = 20060101.
- StartDate = NOW setzt das Startdatum auf den aktuellen Tag und führt die run-Funktion in [Trade]-Modus direkt nach der Lookback-Periode aus, unabhängig von der aktuellen Uhrzeit. Nützlich für Strategien, die nicht dauerhaft laufen, sondern nur zum Ändern eines Portfolios gestartet werden.
- StartDate = 0 (Standard) startet die Simulation mit NumYears vor dem aktuellen Jahr.

EndDate

Ende der Simulation, entweder 4-stellig für das Bestimmen der Nummer der letzten historischen Preisdaten-Datei (ähnlich wie StartDate) oder ein Datum im yyyymmdd-Format, um den Backtest an diesem Datum zu beenden (z.B. 20091231 = 31. Dezember 2009), oder NOW für den aktuellen Tag. Wenn 0 (Standard), läuft die Simulation bis zum Ende der verfügbaren Preishistorie. Im Januar läuft sie bis zum Ende der Preishistorie des Vorjahres.

NumYears

Anzahl der Jahre der Simulation, wenn weder StartDate noch EndDate angegeben sind (Standard: 6 Jahre; maximal 32 Jahre). Das aktuelle Jahr zählt als ein volles Jahr. Setzen Sie NumYears auf -1, um keine Preise über assetHistory zu laden.

MaxBars

Maximale Anzahl Bars der Simulation (Standard: 0 = kein Limit). Die Simulation endet entweder bei EndDate oder nach Erreichen der angegebenen Anzahl Bars (inkl. LookBack-Periode), je nachdem, was zuerst eintritt.

UpdateDays

Intervall in Tagen für das automatische Herunterladen von Preisdaten vom gewählten Broker (Standard: 0 = kein automatischer Download). Der Download-Prozess startet beim ersten Aufruf von asset() in einem [Test]- oder [Train]-Durchlauf, wenn die Preishistorie älter ist als die angegebene Tagesanzahl. Zorro loggt sich dann beim Broker ein, lädt die aktuellen Preisdaten im M1- oder T1-Format (abhängig von History) und fügt sie der Preishistorie hinzu. Diese Variable kann für das Aktualisieren der Daten in einem Retraining oder Retesting-Prozess genutzt werden. Hat keine Wirkung im [Trade]-Modus. Setzen Sie UpdateDays auf -1, um die Preise selbst dann zu laden, wenn die Historie bereits aktuell ist.

ReTrainDays

Intervall in Tagen für das automatische Retraining eines Live-Trading-Systems (Zorro S erforderlich; Standard: 0 = kein automatisches Retraining). Setzen Sie diesen Wert auf die Dauer des WFO-Testzeitraums, um ein WFO-trainiertes System beim Langzeit-Handel ohne Aufsicht synchron mit dem Markt zu halten. Das Intervall beginnt mit dem Start der Session.

GapDays

Maximal erlaubte Lücke in Tagen in den historischen Preisen und in heruntergeladenen Preisdaten (Standard: 0 = keine Prüfung von Lücken). Setzen Sie diesen Wert auf 2 oder höher, um die Preiskurve auf Lücken und Inkonsistenzen zu prüfen. Bei entdeckten Problemen wird Error 047 ausgegeben. Wochenenden und Holidays sind von der Prüfung ausgenommen. Lücken von 1 Tag sind in historischen Preisdaten normal, wenn Marktholidays nicht im Holidays-Array (siehe unten) erfasst sind.

StartWeek

EndWeek

Beginn und Ende der Handelswoche in dhhmm lokaler Zeit in der BarZone, wobei d = Tageszahl (1 = Montag .. 7 = Sonntag), hh = Stunde und mm = Minute. Standard: Start 72300 (Sonntag 23:00), Ende 52000 (Freitag 20:00). Wird benutzt, um das Wochenende für BarMode-Flags zu bestimmen. 

StartMarket

EndMarket

Tägliche globale Marktöffnungs- und -schlusszeit im Format hhmm lokaler Zeit in der BarZone, hh = Stunde und mm = Minute. Standard: 0930. Verwendet für lokale Zeitfunktionen (day, market usw.) und für das Handeln und Bilden von Bars, abhängig von BarMode. Wird automatisch aus AssetMarketStart/End (siehe unten) übernommen, wenn BR_LOCAL gesetzt ist. 

AssetMarketStart

AssetMarketEnd

Lokale Marktöffnungs- und -schlusszeit des ausgewählten Assets im Format hhmm, bezogen auf die lokale Zeit in der AssetMarketZone. Diese Werte werden ursprünglich aus dem Market-Feld der Asset-Liste gelesen, können aber auch per Skript gesetzt werden. Verwendet für Intraday-Trading im BR_LOCAL-Modus. 

Typ:

int

 

Holidays

Zeiger auf ein int-Array mit Feiertagsdaten, entweder im Format yyyymmdd oder mmdd, endend mit 0. Standard: { 0101, 1225, 0 }. Kann auf ein 0-terminiertes Array gesetzt werden, das lokale Börsenfeiertage definiert. Das yyyymmdd-Format spezifiziert einen Feiertag nur in einem bestimmten Jahr, mmdd gilt für alle Jahre.

Typ:

int*
 

Now

Datums-/Zeitvariable im DATE-Format, um einen bestimmten Zeitpunkt an die Funktion contractUpdate oder als NOW-Argument an Datums-/Zeitfunktionen zu übergeben. Ist sie 0 (Standard), wird die aktuelle PC-Zeit für NOW verwendet.

DayOffset

Zeitperiode im DATE-Format, die in [Trade]-Modus zur aktuellen Zeit addiert wird, z.B. um das Live-Verhalten an einem bestimmten Tag, am Wochenende oder bei Marktschluss zu testen (siehe auch Troubleshooting). Setzen Sie diesen Wert z.B. auf 1 (fügt einen Tag hinzu) oder auf 1./24 (fügt eine Stunde hinzu), oder erhöhen Sie ihn bei jedem 1-Stunden-Bar um 1./24, um ein System in doppelter Geschwindigkeit zu traden. Dies beeinflusst auch die Lookback-Periode und die Zeit eines verbundenen Servers, jedoch nicht die Zeitstempel historischer Daten.

Typ:

var
 

Anmerkungen:

  • Der früheste mögliche StartDate wird durch die Verfügbarkeit der historischen Preisdaten bestimmt. M1-Daten bis 2002 können von der Zorro-Website heruntergeladen werden. Im Jahr 2002 wurde der EUR als Ersatz für nationale Währungen eingeführt; daher sind Forex-Backtests vor diesem Datum meist wenig sinnvoll.
  • StartDate und EndDate können genutzt werden, um den Backtest auf einen bestimmten Zeitraum zu "zoomen" und das Handelsverhalten in diesem Zeitraum genauer zu untersuchen.
  • Liegt StartDate vor dem Start der Historie des ersten Assets, beginnt die Simulation oder Lookback-Periode mit der ersten Bar der Historie. Wenn COMMONSTART gesetzt ist, beginnt die Simulation mit dem spätesten Historie-Beginn irgendeines Assets. Die Simulation endet mit dem frühesten Historie-Ende aller Assets oder mit EndDate, je nachdem, was früher eintritt.
  • StartWeek, EndWeek, StartMarket, EndMarket, AssetMarketStart, AssetMarketEnd haben in der Regel wenig Einfluss auf die Bargenerierung, da historische Daten ohnehin keine Preisticks während Marktpausen, Wochenenden oder Feiertagen enthalten. Sie können jedoch verwendet werden, um die Handelszeit einzuschränken oder Handelszeiten in Kombination mit BR_FLAT festzulegen. Beachten Sie, dass sie normalerweise nicht mit den realen Marktöffnungs- und -schlusszeiten übereinstimmen, da sie lediglich Bars oder Indikatoren unterdrücken bzw. zulassen. Für Aktionen exakt zum Markt-Open oder -Close verwenden Sie Ein-Minuten-Bars oder die tick-Funktion. 
  • Alle Variablen, die die Bargenerierung beeinflussen, wie StartDate, EndDate, NumYears, Holidays, UpdateDays usw., müssen gesetzt werden, bevor zum ersten Mal Preisdaten geladen oder asset aufgerufen wird.
  • WFO-Parameter und -Regeln sind nur für den Simulationszeitraum gültig, in dem sie erstellt wurden. Wird der Zeitraum geändert, muss die Strategie neu trainiert werden. Wenn Sie den letzten WFO-Durchgang für das Live-Trading erneut trainieren, setzen Sie EndDate auf 0 oder NOW, sonst würde der Trainingszeitraum mit EndDate enden.
  • Der Initialdurchlauf einer Strategie (INITRUN) besitzt kein gültiges Datum oder Uhrzeit, solange StartDate und EndDate nicht gesetzt und das erste Asset nicht geladen wurde.
  • Um einen 'Fast-Forward'-Modus in einem Live-Trading-Test zu simulieren, nutzen Sie eine tock-Funktion, die bei jeder Minute einen Zeitraum zu DayOffset addiert. Zum Beispiel DayOffset += 9./1440 fügt alle 60 Sekunden 9 Minuten hinzu und lässt die Zeit dadurch 10 Mal schneller vergehen.

Beispiel:

StartDate = 20150901; // startet die Simulation im September 2015
EndDate = 20160901; // und simuliert ein Jahr
static int USHolidays[10] = { 0101, 0218, 0419, 0704, 0527, 0902, 1128, 1225, 0 };
Holidays = USHolidays; // US-Feiertage festlegen

Siehe auch:

bar, BarPeriod, LookBack, Detrend, Zeit-/Datumsfunktionen, PlotDate

 

► neueste Version online