×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.

Changes - MultiCharts
Open main menu

Changes

Outputting Dates in EasyLanguage

153 bytes added, 14:14, 23 February 2012
no edit summary
This article gives some tips and examples for outputting dates in [[:Category:EasyLanguageAbout_EasyLanguage|EasyLanguage]].
== Relevant EasyLanguage Date reserved words ==
Just as a reminder, the following Date reserved words are often used in working with dates:
* <code><b>[[Date]]</code></b>, which returns the Date of the current bar in ''YYYMMdd'' format. This date format is always the format with which a date calculation starts. * <code><b>[[CurrentDate]]</code></b>, returns the current computer date in ''YYYMMdd'' format.* <code><b>[[ELDateToDateTime]]</code></b>, converts a date in ''YYmmdd'' format to a date into DateTime format.
See the [[:Category:Date_and_Time_Routines|Date & Time Routines]] for all EasyLanguage reserved words.
== Outputting the date ==
The following example prints the current date to the [[Editor_Overview|PowerLanguage Editor]] log:
<syntaxhighlight>
Print("The current date is: ", CurrentDate);
Which returns the following sentence: ''The current date is: 1120127.00''.
To output the date in a more readable format, the reserved word <code><b>[[FormatDate]] </code></b> is needed. However, FormatDate requires that the date is in DateTime format, while the default Date is in YYYMMdd format. So, a conversion to DateTime is needed first. This is done with the <code><b>[[ELDateToDateTime]] </code></b> reserved word.
The code example below shows in detail which steps needs to be made.
== Outputting the date in different formats ==
The <code><b>[[FormatDate]] </code></b> reserved word has a parameter string by which different date outputs can be generated. For example, in the code above we used “dd"dd-MM-yyyy” yyyy" to return “27"27-1-2012”2012".
The code example below shows some of these parameter options for FormatDate (see the <code><b>[[FormatDate]] </code></b> article for an extensive list of parameter options).
<syntaxhighlight>