GetPercentComplete()
<< Click to Display Table of Contents >> GetPercentComplete() |
Determines the value your BarsType would return for Bars.PercentComplete
This method returns a double value.
bars |
The bars object chosen by the user when utilizing this Bars type |
now |
The DateTime value to measure |
public override double GetPercentComplete(Bars bars, DateTime now)
{
}
public override double GetPercentComplete(Bars bars, DateTime now) { // Calculate the percent complete for our monthly bars if (now.Date <= bars.LastBarTime.Date) { int month = now.Month; int daysInMonth = (month == 2) ? (DateTime.IsLeapYear(now.Year) ? 29 : 28) : (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ? 31 : 30); return (daysInMonth - (barsSeries.LastBarTime.Date.AddDays(1).Subtract(now).TotalDays / barsSeries.BarsPeriod.Value)) / daysInMonth; // an estimate } return 1; } |