TimeSeriesSynchronizer
Namespace: WealthLab.Core
Parent:

TimeSeriesSynchronizer is a static utility class containing the Synchronize method, allowing you to synchronize a TimeSeries 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 TimeSeries Synchronize(TimeSeries source, TimeSeriesBase master, double? preFillNans = null, MarketDetails market = null)

Synchronizes the source TimeSeries 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 TimeSeries instance that is synchronized with the master.

If the master time series contains data earlier than the source, the resulting synchronized TimeSeries will contain Double.Nan values during that initial period. If the optional preFillNans parameter is a non-null double value, that period will be filled with the specified value instead.

When you are synchronizing daily+ scale to intrday scales, the method needs to utilize the market close time. You can optionally pass a MarketDetails instance in the market parameter to facilitate this, or leave it null to have the method determine the market close time from the data.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Indicators;
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 closing price
			TimeSeries weeklyClose = TimeSeriesCompressor.ToWeekly(bars.Close);

			//calculate 4-week RSI
			RSI rsiWeekly = RSI.Series(weeklyClose, 4);

			//expand it back to daily scale
			TimeSeries expandedRSI = TimeSeriesSynchronizer.Synchronize(rsiWeekly, bars);

			//plot it
			PlotTimeSeries(expandedRSI, "RSI(4-week)", "RSI", Color.Blue);
		}

		//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

	}
}