Search Framework:
BarHistorySynchronizer
Namespace: WealthLab.Core
Parent:

BarHistorySynchronizer is a static utility class containing the Synchronize method, allowing you to synchronize a BarHistory instance with another time series (either a TimeSeries or BarHistory instance). It is useful when you want to plot time series in one scale on a chart based on another scale (for example, weekly to daily).

Static Methods
Synchronize
public static BarHistory Synchronize(BarHistory source, TimeSeriesBase master)

Synchronizes the source BarHistory instance with the master TimeSeriesBase instance. The master parameter can be either a TimeSeries or a BarHistory instance, as both descend from TimeSeriesBase. The method returns a new BarHistory instance that is synchronized with the master.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using System.Drawing;

namespace WealthLab
{
	public class MyStrategy1 : UserStrategyBase
	{
		//create indicators and other objects here, this is executed prior to the main trading loop
		public override void Initialize(BarHistory bars)
		{
			//get weekly data
			BarHistory weekly = BarHistoryCompressor.ToWeekly(bars);

			//synchronize it back to the original (daily) scale
			BarHistory weeklySynched = BarHistorySynchronizer.Synchronize(weekly, bars);

			//plot the monthly bars on top of the daily
			PlotBarHistory(weeklySynched, "Price", WLColor.FromArgb(62, 0, 0, 0));
		}

		//execute the strategy rules here, this is executed once for each bar in the backtest history
		public override void Execute(BarHistory bars, int idx)
		{
		}

		//declare private variables below

	}
}