I was wondering if someone could help me code a strategy. Shouldn't be to terribly difficult but I can't seem to get it working. It would consist of a simple moving average, market cap, and 52 week market high. If specific parameters are met it would buy and hold for a week.
Let me know if you are interested. If I'm correct the results will be pretty nice.
Alexandre Catarino
We made some changes on the EmaCrossUniverseSelectionAlgorithm to include the 52 week market high. Since you didn't specify how we create a score to pick the stocks, we came out with this:
public decimal ScaledDelta { get { var smaScore = (Fast - Slow)/((Fast + Slow)/2m); var maxScore = (Max - _value)/((Max + _value)/2m); return smaScore + maxScore; } }
Market cap is not available in out Fundamentals database. Please checkout the available data here. As an example, we have used P/E ratio instead:
public IEnumerable<Symbol> FineSelectionFunction( IEnumerable<FineFundamental> fine) { // sort descending by P/E ratio var sortedByPeRatio = fine .OrderByDescending(x => x.ValuationRatios.PERatio); // take the top entries from our sorted collection var topFine = sortedByPeRatio.Take(2); // we need to return only the symbol objects return topFine.Select(x => x.Symbol); }
Here are the basics for your algorithm.
TheGingerAle
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!