HistoryScale
Namespace: WealthLab.Core
Parent: Object

The HistoryScale class represents a data time scale, for example daily, weekly, or 5-minute intraday scales.

Constructor
HistoryScale
public HistoryScale(HistoryScales scale, int interval = 0)

The HistoryScale constructor takes a scale parameter of type HistoryScales which is an enumerated type. Possible values are Daily, Weekly, Monthly, Quarterly, Yearly, Tick, Second, and Minute. The interval parameter is the interval for Tick, Second or Minute scales.



Members
Description
public string Description

Returns a description of the scale.

Example Code
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
    {
        //display the scale of the chart
        public override void Initialize(BarHistory bars)
        {
			DrawHeaderText("The current scale is: " + bars.Scale.Description);
        }

        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

Interval
public int Interval

Represents the time interval for Minute, Second and Tick scales.

Example Code
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
    {
        //create indicators and other objects here, this is executed prior to the main trading loop
        public override void Initialize(BarHistory bars)
        {
			DrawHeaderText("Bar Scale = " + bars.Scale.Scale);
			DrawHeaderText("Bar Interval = " + bars.Scale.Interval);
        }

        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

IsIntraday
public bool IsIntraday

Returns true if this HistoryScale represents an intraday scale. Intraday scales are Tick, Second, and Minute.

Example Code
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
    {
        //create indicators and other objects here, this is executed prior to the main trading loop
        public override void Initialize(BarHistory bars)
        {
			if (bars.Scale.IsIntraday)
				DrawHeaderText("Intraday Chart!", Color.Red);
        }

        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

Scale
public HistoryScales Scale

Denotes what kind of scale this HistoryScale represents, as a HistoryScales enum. Possible values are Daily, Weekly, Monthly, Quarterly, Yearly, Tick, Second, and Minute.

Example Code
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
    {
        //create indicators and other objects here, this is executed prior to the main trading loop
        public override void Initialize(BarHistory bars)
        {
			DrawHeaderText("Bar Scale = " + bars.Scale.Scale);
			DrawHeaderText("Bar Interval = " + bars.Scale.Interval);
        }

        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

Static Helpers
public static HistoryScale Daily = new HistoryScale(HistoryScales.Daily)
public static HistoryScale Weekly = new HistoryScale(HistoryScales.Weekly)
public static HistoryScale Monthly = new HistoryScale(HistoryScales.Monthly)
public static HistoryScale Quarterly = new HistoryScale(HistoryScales.Quarterly)
public static HistoryScale Yearly = new HistoryScale(HistoryScales.Yearly)

This collection of static variables can be referenced as shortcuts to commonly used scales.