本文整理汇总了C#中BarList.Time方法的典型用法代码示例。如果您正苦于以下问题:C# BarList.Time方法的具体用法?C# BarList.Time怎么用?C# BarList.Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BarList
的用法示例。
在下文中一共展示了BarList.Time方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBarIndexPreceeding
/// <summary>
/// gets preceeding bar by time (assumes same day)
/// </summary>
/// <param name="chart"></param>
/// <param name="time"></param>
/// <returns></returns>
public static int GetBarIndexPreceeding(BarList chart, int date, int time)
{
// look for previous day's close
for (int j = chart.Last; (j >= chart.First); j--)
{
if (chart.Date()[j] > date) continue;
if (chart.Time()[j] < time)
{
return j;
}
}
// first bar
return -1;
}
示例2: BarExists
/// <summary>
/// check if bar already exists in current bar list (assumes same day)
/// </summary>
/// <param name="chart"></param>
/// <param name="time"></param>
/// <returns></returns>
public static Boolean BarExists(BarList chart, Bar b)
{
System.Diagnostics.Debug.Write("HellofromBarExists\t");
System.Diagnostics.Debug.Write(b.Bardate); System.Diagnostics.Debug.Write("\t");
System.Diagnostics.Debug.Write(b.time); System.Diagnostics.Debug.Write("\n");
long date = b.Bardate;
int time = b.time;
// look for same bar. This should occur mostly in backfilling. So when dealing with realtime data, there could still be multiple ticks/bars with the same timestamp.
for (int j = chart.Last; (j >= chart.First); j--)
{
/*
long chartDate = chart.Date()[j];
int chartTime = chart.Time()[j];
if (chart.Date()[j] > date) continue;
if (chart.Time()[j] > time) continue;
*/
if (chart.Date()[j] > date) continue;
if (chart.Date()[j] == date && chart.Time()[j] > time) continue;
else
{
if (chart.Date()[j] < date) return false;
if (chart.Date()[j] == date && chart.Time()[j] == time) return true;
if (chart.Date()[j] == date && chart.Time()[j] < time) return false;
}
}
//no hit
return false;
}