Hello … I've been playing around with a long swing trade idea and I'd like to backtest it on Quantconnect. I've been a lurker here for awhile but I'm still pretty new to the the platform environment. I code as a hobby and I'm trying to devote some time to dig in and develop my understanding. The strategy I'm toying with is based on a screener algorithm that I wrote in Python that runs close to end of day that returns a list of equities that have crossed above the Fractal Adaptive Moving Average (FRAMA) before close. There are some other filtering parameters, but the goal is to buy the best candidates on the returned watchlist at close and hold them until a predefined gain is met or a stop is hit, limiting the portfolio to a manageable number of equities.
I've written the screen in native Python using a combination of open source libraries. I'm not the best or most efficient coder, but my screen works, so it makes me happy! I'm struggling though to translate my logic to Quantconnect. Mainly because I'm trying to figure out how to filter my universe through Quantconnect's implementation of the FRAMA class. I've been looking for examples but my main question is how do I use Quantconnect's FRAMA class as a coarse or fine filtering indicator to detect upside crossovers on the daily chart and add them to a watchlist allowing the option to buy at close? I'm gonna keep working on it but any starter code that would point me in the right direction would be wonderful.
I appreciate anyone willing to chime in, this been a fun project to play with, but I'd like to take it up a notch. Cheers!
Mia Alissi
Hello JP,
It's great to hear that you're interested in using QuantConnect for your backtesting needs. Based on the information provided in the extracts, it seems you're looking to use the Fractal Adaptive Moving Average (FRAMA) as a filter in your universe selection.
While the extracts don't provide a direct example of using FRAMA in universe selection, they do provide some guidance on how to use indicators and universe selection in general.
In QuantConnect, you can create and update indicators like FRAMA in your algorithm. This is usually done in the Initialize method. You can also use the CoarseSelectionFunction and FineSelectionFunction to filter your universe of stocks.
Here's a basic structure of how you might set up your algorithm (note: this is a pseudo-code and might not run as-is):
For more detailed examples and guidance, I recommend checking out the QuantConnect documentation, Boot Camp, and example algorithms on GitHub.
I hope this helps you get started with your project. Happy coding!
Sources:
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!