Parent: Object
The HistoryScale class represents a historical data scale, such as daily, weekly, monthly, or a 5-minute intraday scale. It implements the IComparable interface, allowing HistoryScale instances to be compared according to their relative granularity.
The parameterless constructor creates an uninitialized HistoryScale instance. The second constructor assigns the Frequency and Interval properties. The scale parameter specifies the Frequency, while interval specifies the interval for scales that use one, such as Minute, Hour, Second, Tick, Volume, and NDays.
Returns an abbreviated description of the scale suitable for charting and other compact displays. Examples include "(D)" for Daily, "(W)" for Weekly, "(M5)" for 5-minute, "(H2)" for 2-hour, and "W(Monday)" for a WeeklyStartDay scale.
Returns the DateTime that results from adding one interval of this HistoryScale to dt. For example, a Daily scale adds one day, a Quarterly scale adds three months, and a 5-minute scale adds five minutes.
Returns a DateTime adjusted backward by the number of bars specified in leadBars, using the current HistoryScale. This can be used to determine an earlier starting date when additional lead bars are required.
Returns a new HistoryScale instance having the same Frequency, Interval, and FilterPrePost values as this instance.
Returns a description of the scale. Scales that use an interval include the interval in the description, for example "5 Minute", "2 Hour", or "1000 Volume". Other scales return the name of their Frequency.
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.ChartWPF; using System.Drawing; using System.Collections.Generic; namespace WealthLab { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { DrawHeaderText("The current scale is: " + bars.Scale.Description); } public override void Execute(BarHistory bars, int idx) { } } }
Returns whether this HistoryScale is divisible by the specified scale. If the two scales have different Frequency values, the method returns true. If they have the same Frequency, the method returns true when this instance's Interval is evenly divisible by the specified scale's Interval.
Determines whether pre-market and post-market data should be filtered from intraday historical data. The default value is true.
Formats the specified DateTime according to this HistoryScale. Intraday scales include the time, yearly and higher scales display the year, monthly scales display the month and year, and other scales use a short date representation.
The Frequency represented by this HistoryScale. Supported Frequency values include intraday and higher scales such as Tick, Volume, Second, Minute, Hour, Daily, NDays, Weekly, WeeklyStartDay, BiWeekly, Monthly, Quarterly, SemiAnnually, and Yearly.
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.ChartWPF; using System.Drawing; using System.Collections.Generic; namespace WealthLab { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { DrawHeaderText("Bar Frequency = " + bars.Scale.Frequency); DrawHeaderText("Bar Interval = " + bars.Scale.Interval); } public override void Execute(BarHistory bars, int idx) { } } }
Creates a HistoryScale from its string representation. Recognized values include scales such as "Daily", "Weekly", "Monthly", "Quarterly", "SemiAnnually", and "Yearly", as well as interval-based descriptions such as "5 Minute", "2 Hour", "1000 Volume", and "3 Day". WeeklyStartDay values such as "Weekly(Monday)" are also supported. Returns null if s cannot be converted to a valid HistoryScale.
Returns an estimated maximum number of bars that can occur between startDate and endDate, assuming a 24/7 market. This method supports Daily, Weekly, WeeklyStartDay, Monthly, Quarterly, SemiAnnually, Yearly, and Minute scales. It throws a NotSupportedException for unsupported scales.
Returns an estimated starting DateTime for a range ending at endDate and containing numBars bars. This method supports Daily, Weekly, WeeklyStartDay, Monthly, Quarterly, SemiAnnually, Yearly, and Minute scales. It throws a NotSupportedException for unsupported scales.
Returns a string containing the specified symbol and scale, separated by a semicolon. If includeInterval is false, only the Frequency portion of the scale is included.
Represents the interval for scales that use an interval component, such as Minute, Hour, Second, Tick, Volume, and NDays.
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.ChartWPF; using System.Drawing; using System.Collections.Generic; namespace WealthLab { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { DrawHeaderText("Bar Scale = " + bars.Scale); DrawHeaderText("Bar Interval = " + bars.Scale.Interval); } public override void Execute(BarHistory bars, int idx) { } } }
Returns true if this HistoryScale represents an intraday scale. Intraday scales are Tick, Volume, Second, Minute, and Hour.
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.ChartWPF; using System.Drawing; using System.Collections.Generic; namespace WealthLab { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { if (bars.Scale.IsIntraday) DrawHeaderText("Intraday Chart!", WLColor.Red); } public override void Execute(BarHistory bars, int idx) { } } }
Returns true if the HistoryScale is based on individual market activity rather than elapsed time. This is true for Tick and Volume scales.
Returns true if the HistoryScale is time based. Time-based scales include Second, Minute, Hour, Daily, NDays, Weekly, WeeklyStartDay, Monthly, Quarterly, SemiAnnually, and Yearly.
Creates a HistoryScale from its persisted string representation.
Returns a persisted string representation of the HistoryScale, including its Frequency, Interval, and FilterPrePost values.
Returns the DateTime that results from subtracting count intervals of this HistoryScale from dt.
Returns the Description of the HistoryScale.
Returns true when the Interval property is used when comparing and sorting HistoryScale instances. This is true for intraday scales and NDays.
These predefined HistoryScale instances provide convenient shortcuts for commonly used scales. For example, HistoryScale.Daily represents a daily scale, while HistoryScale.Minute5 represents a 5-minute scale.