Lookup Method
Developers can use the Lookup function to retrieve specific bar data from the TimeDataSeries based on a datetime or timenum of interest. The function searches through the TimeDataSeries to find the bar that matches the specified datetime or time representation (timeNum).
public IBarData Lookup(DateTime dateTime)
public IBarData Lookup(int timeNum)
int targetTime = 1315; // Example target time representation for 13:15 PM
IBarData targetBar = tdSeries.Lookup(targetTime);
DateTime targetDateTime = new DateTime(2024, 03, 30, 09, 35, 0); // Example target datetime
IBarData targetBar = tdSeries.Lookup(targetDateTime);
Date and Time based function of TimeDataSeries
| Functions | Description |
|---|---|
| TimeNum | Return at given bar index the Time value in format HHmmss. If time at bar index 10 is 11:15:00, the value it return is 111500 int timeNum = tdSeries.TimeNum(10); |
| DayOfWeekNum | Returns the array with day of week (0-6): 0 - Sunday 1 - Monday 5 - Friday 6 - Saturday |
| DayOfMonth | Return the day part |
The utility class QX.FinLib.Common.Util.DateTimeUtil extends some more useful functions on DateTime structure.
General Utility methods supported in TimeDataSeries
| Method | Description |
|---|---|
| int TimeNum(int barIndex) | Returns time in HHmmss format (e.g. 091500) |
| int TimeNum(int hour, int minute, int second) | Converts given time into TimeNum format |
| int DateNum(int barIndex) | Returns date in yyyyMMdd format |
| bool IsFirstBarOfDay() | True if first bar of the day |
| bool IsLastBarOfDay() | True if last bar of the day |
| int DayOfWeekNum(int barIndex) | Day of week (Monday=1 … Sunday=0) |
| int DayOfMonthNum(int barIndex) | Returns day of month (1–31) |
| bool IsGapUp() | True if today’s open > yesterday’s high |
| bool IsGapDown() | True if today’s low < yesterday’s low |
| bool IsInside() | True if inside bar |
| IBarData GetDailyTimeFrameBar(int refBarIndex = 0, bool includeTodaysDate = true) | Returns daily bar data |
| bool IsRising(int index) | Value > previous |
| bool IsFalling(int barIndex) | Value < previous |
| double UpperShadow(int barIndex) | Length of upper wick |
| double LowerShadow(int barIndex) | Length of lower wick |
| int BarsSince(Func(int, bool) evaluateFuncAtBarIndex, int nthOccuranceTimes = 1) | Returns bar index since condition |
| double HighestSince(Func(int, bool) evaluateFuncAtBarIndex, char priceType = 'C', int nthOccuranceTimes = 1) | Highest value since condition |
| double LowestSince(Func(int, bool) evaluateFuncAtBarIndex, char priceType = 'C', int nthOccuranceTimes = 1) | Lowest value since condition |
| double ValueWhen(Func(int, bool> evaluateFuncAtBarIndex, char priceType = 'C', int nthOccuranceTimes = 1) | Value when condition met |
| double LLV(int lengthPeriod) | Lowest low value |
| double LLV(char priceType, int lengthPeriod) | Lowest low for price type |
| double HHV(int lengthPeriod) | Highest high value |
| double HHV(char priceType, int lengthPeriod) | Highest high for price type |
| double StdDev(int lengthPeriod) | Standard deviation |
| double Sum(int lengthPeriod) | Sum of values |
| double Sum(char priceType, int lengthPeriod) | Sum by price type |
| double Average(int lengthPeriod) | Average value |
| double WeightedAverage(int lengthPeriod) | Weighted average |
| double TrueRange(int barIndex) | Measures daily range |
| double TypicalPrice(int barIndex) | (High + Low + Close) / 3 |