CalcDate (Function)
The CalcDate function adds and subtracts days from a reference date. The reference date is a numeric value in the EasyLanguage date format: YYYMMDD (Year Month Day).
For example, 1030101 = Jan. 1st, 2003 or 9906015 = June 15, 1999
Since EasyLanguage and Chart Analysis use this special date format, it is sometimes difficult to add or subtract some number of days from the EasyLanguage date. For example, if you wanted to subtract 15 days from Jan 1, 2003, you might try 1030101 – 15, which would result in an invalid date, CalcDate solves this by returning the correct and valid date of 1021216
Syntax
CalcDate(RefDate,DaysChange)
Returns (Integer)
A numeric value the represents the date in EasyLanguage format for the current bar.
Parameters
Name |
Type |
Description |
RefDate |
Numeric |
Specifies a chart date in EasyLanguage date format to use as the reference date for the calculation, entered in YYYMMDD format. (Examples: 1030415, 991015, or 1000505) |
DaysChange |
Numeric |
Sets the days to be added (positive value) or subtracted (negative value). |
Remarks
EasyLanguage does not see time and date as unique data formats but sees them and treats them as normal numeric values.
The reserved words date and CurrentDate return numeric date values in an EasyLanguage format (YYYMMDD).
Example
Assigns to Value1 the calculated date 14 days prior to the current bar date to value1:
Value1 = CalcDate(Date,-14);