Using indicators with custom tradebar intervals?

I am using a custom tradebar interval as such:

using QuantConnect.Data.Consolidators;

namespace QuantConnect
* QuantConnect University: Consolidator Example of Generic Timespan Bars
public class QCUConsolidatorExample : QCAlgorithm

TradeBarConsolidator _consolidator;
private const string symbol = "EURUSD";

//Initialize the data and resolution you require for your strategy:
public override void Initialize()

//Start and End Date range for the backtest:
SetStartDate(2013, 1, 1);

//Cash allocation

//Add as many securities as you like. All the data will be passed into the event handler:
AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Minute);

//Consolidator Obj:
_consolidator = new TradeBarConsolidator( TimeSpan.FromMinutes(30) );
_consolidator.DataConsolidated += EURUSD_30;

SubscriptionManager.AddConsolidator("EURUSD", _consolidator);

//create TEMAs


public void EURUSD_30(Object o, TradeBar bar)
Log(Time.ToString("u") + " Close Price: " + bar.Close);

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
// "TradeBars" object holds many "TradeBar" objects: it is a dictionary indexed by the symbol:
// e.g. data["MSFT"] data["GOOG"]


I have read the docs and examples on using indicators, however I never saw anything about using indicators with custom tradebar intervals.

How would I create a simple MA on a custom 30 minute tradebar interval?

Update Backtest

Hi Sean McKenna! I have found an example in another thread, Basically, you need to create an indicator from its contructor, not the helper method, and register it:

var fiveMinuteConsolidator = new QuoteBarConsolidator(TimeSpan.FromMinutes(30));
var sma = new SimpleMovingAverage("SMA_" + symbol, 5);
RegisterIndicator(symbol, atr, fiveMinuteConsolidator);

In the attached project, we have a situation with two symbols and two indicators. 
Ah! Please note that with forex we need to use QuoteBarConsolidator, since forex data type is quote bar, not trade bar.


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed