GetPercentComplete()

View as Markdown

Definition

Determines the value your BarsType would return for Bars.PercentComplete.

Method Return Value

This method returns A double value.

Method Parameters

ParameterDescription
barsThe bars object chosen by the user when utilizing this Bars type
nowThe DateTime value to measure

Syntax

You must override the method in your Bars Type with the following syntax.

public override double GetPercentComplete(Bars bars, DateTime now) \{ \}

Examples

1public override double GetPercentComplete(Bars bars, DateTime now)
2{
3 // Calculate the percent complete for our monthly bars
4 if (now.Date <= bars.LastBarTime.Date)
5 {
6 int month = now.Month;
7 int daysInMonth = (month == 2) ? (DateTime.IsLeapYear(now.Year) ? 29 : 28) :
8 (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ? 31 : 30);
9 return (daysInMonth - (barsSeries.LastBarTime.Date.AddDays(1).Subtract(now).TotalDays / barsSeries.BarsPeriod.Value)) /
10 daysInMonth; // an estimate
11 }
12 return 1;
13}