Your interactive trading laboratory!
 • 
23 users online

Quantacula Help

How-To
C# API Reference
Extensions
Development Blog
API-Extensions
Indicator Spotlights

QCommunity Extensions
The open-source GitHub repository of source code for the QCommunity Extensions library. Contains indicators and other extensions submitted by the Quantacula Community. Look for QCommunity indicators when you create a Building Block model, mark the "QCommunity" library check box to expose them.

TASC-Extensions
The open-source GitHub repository of source code for the TASCExtensions Quantacula extension. Contains indicators and other extensions adapted from the Traders' Tips articles in Technical Analysis of Stocks & Commodities magazine.
TimeSeriesSynchronizer
Namespace: Quantacula.Core
Parent: none (static)

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)

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.

Example Code
using Quantacula.Backtest;
using Quantacula.Core;
using Quantacula.Indicators;
using System.Drawing;

namespace Quantacula
{
	public class MyModel1 : UserModelBase
	{
		//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 = TimeSeriesSynhronizer.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

	}
}