Someone please post an example of how to feed indicators, let's say moving average with custom data as I have started to get into new engine and it seems it will require a lot of time to understand how architecture works exactly. Examples are faster, haha :)
Michael H
RegisterIndicator(symbol, indicator, resolution);
Under the hood what we're doing is creating an object whose job it is to consolidate your data, and then feed it to your indicator on the requested resolution. This is easy for us to do when your data is of type TradeBar, which is the normal type for data supplied by the Lean Engine. Things get a little more complicated with custom data. With custom data we don't know anything about the type, so you're forced to provide us with the object that will do the consolidation. This object is called a data consolidator and implements the IDataConsolidator interface. When we call the RegisterIndicator function, what we're really doing is subscribing the consolidator for data and telling the consolidator to update our indicator for us when he has a new piece of consolidated data. This is done through C# events. Check out the Data Consolidation example algorithm for more on what consolidators can do. So what I've done in this example is come up with a new consolidator that will work on types with the following properties defined: Time, Open, High, Low, Close, Volume (OHLCV), no matter what type it is. I use dynamics to get the OHLCV data out of your custom data object (such as Quandl) and into a TradeBar, which can then be fed to the standard TradeBarConsolidator. If you have any questions or comments on how all this works, please don't hesitate to ask! Let me know if this helps your problem!Jared Broad
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.
Tadas Talaikis
Michael H
// without this line the plot doesn't show up in the ui Plot(SPY_QuandlCode, emaClose.Name, data.Value);
I believe this may be a bug, I haven't had time to investigate it. Without this call to Plot here I wasn't getting any plots, but with it, the plots worked.Tadas Talaikis
Michael H
Michael H
Tadas Talaikis
Jared Broad
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.
Michael H
var ema = new ExponentialMovingAverage(5); RegisterIndicator(symbol, ema, Resolution.Daily, x => { var btc = (Bitcoin)x; return Math.Abs(btc.Close - btc.Open); });
This code will produce the exponential moving average of the absolute difference between the close and the open.Tadas Talaikis
Tadas Talaikis
Michael H
// defined in Initialize() sma = new SimpleMovingAverage(10); // used in OnData sma.update(tradeBar.Time, tradeBar.Value);
Tadas Talaikis
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!