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.
private RollingWindow Avg1;
Avg1.Add(new IndicatorDataPoint(this.time, XAverage.Current.Value);
if (Avg[0].Value == Avg[1].Value){
// do something
}
var ema = EMA("SPY", 40);
We can put the old emas into a rolling window as suggested by @Nicholas:int historyLength = 10;
var window = new RollingWindow(historyLength);
// this next line says each time we get a new ema value, add it to our window
ema.Updated += (sender, args) => window.Add(args);
Now we can access and compare the way @Nicholas shows: // if today's ema is greater than yesterday's ema
if (window[0] > window[1]){
// do something magic
}
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.
I know this is an old thread, but would this code go in the initialize or the OnData event. Specifically for the .Updated event to fire. Does that happen no matter where you call EMA()? Thanks
on the right there are some examples provided by the QC team.
check them out
there is for example one file called MovingAverageCrossAlgorithm. which you can copy paste into the algo lab and play with that.
(its an ema crossover example)
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!