ToDay()

View as Markdown

Definition

Calculates an integer value representing a date.

Integer representation of day is format as yyyyMMdd where January 8, 2015 would be 20150108.

Method Return Value

An int value representing date structure.

Syntax

ToDay(DateTime time)

Parameters

ParameterDescription
timeA DateTime structure to calculate. Note: See also the Time property.

Tip: NinjaScript uses the .NET DateTime structures which can be complicated for novice programmers. If you are familiar with C# you can directly use DateTime structure properties and methods for date and time comparisons otherwise use this method and the ToTime() method.

Examples

1protected override void OnBarUpdate()
2{
3 // Compare the date of the current bar to September 15, 2014
4 if (ToDay(Time[0]) > 20140915)
5 {
6 // Do something
7 }
8}