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

TimeSeriesCompressor is a static utility class containing methods that let you compress a TimeSeries instance from one scale down to a more compressed scale. For example, you can call TimeSeriesCompressor.ToWeekly to compress a daily TimeSeries into a weekly one.

If you want to be able to plot a compressed TimeSeries onto the chart, you would need to first expand it back to the original scale. You can use the TimeSeriesSynchronizer utility class to accomplish this.

Static Methods

ToDaily
public static TimeSeries ToDaily(TimeSeries source)

Compresses the source TimeSeries to a daily scale, returning a new TimeSeries instance.


ToMonthly
public static TimeSeries ToMonthly(TimeSeries source)

Compresses the source TimeSeries to a monthly scale, returning a new TimeSeries instance.


ToQuarterly
public static TimeSeries ToQuarterly(TimeSeries source)

Compresses the source TimeSeries to a quarterly scale, returning a new TimeSeries instance.


ToWeekly
public static TimeSeries ToWeekly(TimeSeries source)

Compresses the source TimeSeries to a weekly scale, returning a new TimeSeries instance.

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

	}
}

ToYearly
public static TimeSeries ToYearly(TimeSeries source)

Compresses the source TimeSeries to a yearly scale, returning a new TimeSeries instance.