Back

Auto Adjusting MA Crossover Periods

Hi guys! This is my first algorithm coded just this afternoon. This keeps track of 80 EMAs from 1 minute to 3 days. Each step it does a comparison of gains from all possible EMA pairs and uses the recent best performing pair to execute its next trade.
Update Backtest








Nice work, have you tried it over a longer period? MSFT is a nice stable stock for moving averages, all MA's tends to break with volatility. Maybe could find other heavy/slow/stable stocks to smooth curve further?
0

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.


Nice, have you tried in real time or you tested for historical data? If you tested for historical data, don't forget about quotes and priority of execution orders, that could confuse backtesting for historical data and real-time testing, because when you test on historical data, your quotes was taken in high priority.
0

Hi, thanks for commenting. I have only tested on historical data so far using the built in Order method. I'm not going super short term and am operating on the minute scale so I hope order execution has less of an effect on the results. Also, I fixed some flaws with the algorithm this morning and am now waiting for a new backtest to complete. I'm hoping the new results will be much better!
0

Sorry @Grant worker servers crashed this morning I had to reboot the cloud with newer faster machines. You might need to re-run that last job.
0

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.


@Jared, no problem. By the way, I'm wondering if deleting a simulation result cancels the actual backtesting worker?
0

At the moment no :) Its easier to just let the jobs finish. The cloud has auto-scaling to infinite machines but at the moment its disabled to keep the server costs low.
0

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.


Here is the backtest and source from a somewhat failed "improvement". It was supposed to look for the moving average crossovers that made the fastest gains while the original algorithm looked for the crossovers with the longest runs. Some things I will work on are:

Improving the scoring criteria for determining which periods to use, include things like risk
Using some additional "indicators" to gauge likelihood of success, maybe look at slopes of the MAs
Improving exit strategy. Right now, I am only trading on crossovers. There needs to be some kind of stop loss.
Once I optimize the algorithm to be a little faster, I will start tracking multiple companies.
0


Here's the original algorithm for a longer period of time. There's still a lot of work to be done on both of these strategies that could improve them a lot.
5


When designing a strategy like this, it's important to ask yourself why it would work.
0

So this was the first algorithm I ever wrote and I don't have an algorithmic trading background. I guess since then I've realized that I was actually implementing a very crappy version of particle swarm optimization and also that MA crossovers aren't even the best thing to use anyway. I do want my algorithms to adapt over time and I try to write them with as few tunable parameters as possible.
0

Update Backtest





0

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.


Loading...

This discussion is closed