Your interactive trading laboratory!
 • 
17 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.
BarHistorySynchronizer
Namespace: Quantacula.Core
Parent: none (static)

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 Quantacula.Backtest;
using Quantacula.Core;
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 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", Color.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

	}
}