bar | Offset of the bar for which the date or time is returned; 0 for the current bar, 1 for the previous bar and so on. When multiple time frames are used, bar offsets are multiplied with TimeFrame. |
offset | Offset of the bar for which the date or time is returned; or NOW for the current PC time; or a day number in DATE format with no decimals. |
zone | UTC for UTC/GMT time, WET for London, CET for Frankfurt, EST for New York, CST for Chicago, JST for Tokyo, AEST for Sydney, or the zone offset in hours, from -12...+12 (with daylight saving) or from UTC-12..UTC+12 (without daylight saving). For the daylight saving period, US periods are used for time zones -4 or below, Australian periods are used for time zones 10, 11, 12, and European periods for all other time zones. Note that JST is defined as UTC+9 since Japan uses no daylight saving. |
Format | Format string, see format codes. Some often used format strings are predefined in variables.h: YMD = "%Y%m%d"; HMS = "%H:%M:%S"; YMDHMS = "%y%m%d %H:%M:%S". |
offset | Bar offset, 0 for the current bar, 1 for the previous bar and so on, or NOW for the current time (see remarks). |
YYYYMMDD | Date as integer, f.i. 20180403 for April 3, 2018. |
Date | Date/time in Windows DATE format, as returned from wdate(). Days are represented by whole number increments starting on Saturday, 30 December 1899, midnight UTC. The time of the day is represented in the fractional part of the number. This format allows easy and precise date comparison down to a microsecond (= 0.000001/(24*60*60)). |
DateTime | Date/time string in various formats, see format codes. |
zone | UTC for UTC time, ET for New York, WET for London, CET for Frankfurt, AEST for Sydney, JST for Tokyo, or a number giving the zone offset in hours to UTC. Daylight saving time is considered in non-UTC zones from 2000 to 2024. |
days | Number of days in the past, or 0 for the day of the current bar, or a negative number for days in the future. |
hour | Hour of the day, 0..23. If above 23, days is adjusted accordingly. |
minute | Minute of the hour, 0..59. If above 59, hour is adjusted accordingly. |
// buy at UTC midday on the last day of the month, // sell 2 trading days later if(NumOpenLong == 0) { // nothing yet bought this month if((tom(0) == tdm(0)) && hour() >= 12) enterLong(); } else if(tdm(0) >= 2) exitLong(); // print New York local time to the log
printf(strdate("# NY: %H:%M",EST,0)); // close all position at 16:15 local time if(at(1615)) { printf("\nClosing all positions"); exitLong("**"); exitShort("**"); } // convert a time stamp from EST to UTC TimeStamp -= (EST+dst(EST,TimeStamp))/24.;