Greetings Ladys and Gents,
I´m pretty new to Quantconnect and this is my first algorithm I think is worth sharing.
I have tried to implement a fairly simple strategy, which consists of 3 Exponential-Movingaverages and a trailing stop loss. The rules to this strategy are simple. If an up trend is identified and the price closes between the 20 and 50-EMA the algorithm takes a long position. Furthermore it closes the position if the price closes underneath the 50-EMA or the trailing stop loss criteria is meet.
I have to admit that this backtest is cherry picked and the algorithm performes worse on a larger time scale.
If you have any suggestions on how I could ipmrove my algorithm please feel free to comment.
Derek Melchin
Hi Frederik,
Great start on this algorithm! There are just a few things we can do to improve it:
#1 Replace
not self.twenty.IsReady and self.fifty.IsReady and self.hundred.IsReady
with
not (self.twenty.IsReady and self.fifty.IsReady and self.hundred.IsReady)
#2 When trading crypto, we should avoid using CalculateOrderQuantity. We should manually calculate the order quantity using the CashBook instead.
target_quantity = 0.9 * self.Portfolio.TotalPortfolioValue / price quantity = target_quantity - self.Portfolio.CashBook['BTC'].Amount
#3 We should rearrange the code so that the trailing stop loss can still be hit when BTC is in a downtrend.
See the attached backtest for reference.
Best,
Derek Melchin
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.
Frederik W.
Thanks for the help Derek, I really appreciate it.
Frederik W.
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!