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);
SetEndDate(DateTime.Now.Date.AddDays(-1));
//Cash allocation
SetCash(25000);
//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?
Sean McKenna
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!