I've thrown together an example algorithm that shows how to define indicators on any time frame using a consolidator. I also show how you can combine multiple indicators into more complex things like ratios and even indicators of indicators.
Let me know what you guys think!
Nik milev
Sri Vanama
Nicholas Caffrey
Michael Handschuh
Nicholas Caffrey
Michael Handschuh
Nicholas Caffrey
Michael Handschuh
var emaHigh = EMA("SPY", 20, Resolution.Minute, Field.High);
Michael Handschuh
Nicholas Caffrey
Michael Handschuh
Michael Handschuh
Nicholas Caffrey
Nicholas Caffrey
Michael Handschuh
// in initialize RegisterIndicator(Symbol, myIndicator, myConsolidator, AveragePriceSelector); public static decimal AveragePriceSelector(BaseData data) { var bar = (TradeBar)bar; return (bar.High + bar.Low)/2; }
Also, check out the Field.SevenBar which performs an averaging scheme on OHLC data.Nicholas Caffrey
Michael Handschuh
Jonathan Andre
Michael Handschuh
var ema15 = EMA("SPY", 15, Resolution.Minute);
The other method involves manually instantiating the class using the constructor. This is not directly tied to any security when you construct it, but instead we can register it to receive data from other indicators or from a consolidator. In the attached project here I'm manually instantiating the indicators because I want to use them on the 15 bars produced by my consolidator object, so I use method 2:var Symbol = "SPY"; var ema = new ExponentialMovingAverage("this is an indicator name", 15); RegisterIndicator(Symbol, ema, TimeSpan.FromMinutes(15));
So to answer your question, the "SPY_EMA15" is just the name of the indicator object and can be an arbitrary string. The indicator name is used by the helper Plot functions for the series name, so be sure to make it unique! I like to use names that indicator where the data came from ("SPY") and what I did with it ("EMA15"). Here's a link to the constructor in question. You can also navigate up a level to see all the code for all the indicators.Jonathan Andre
Michael Handschuh
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!