LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
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.
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.
Douglas Stridsberg
5.1k Pro
,
Hi Christian,
There's a few things going on in your code which I think are mistakes/incorrect. From top to bottom:
You say you have a stop loss of 1% but your stop_price variable is set to 2% of the open. Be careful in defining exactly what kind of stop loss you want and what price it should reference. I'm aware you're not using this variable anywhere in your code, but just pointing it out to you.
Your comments read "15 day" and "30 day" EMAs but you're not at all creating them with those parameters. Again, you're not even using the slow EMA but I just wanted to point this out to you in case you've missed it.
At the very end of your code, your if statement reads "if 99% of the close is more than the close, liquidate". That's never going to trigger, so if you're relying on that piece of your code to do the stop loss, then that explains why you're seeing greater average losses.
In general, for your sake and for the sake of the people on the forums who want to help, I would recommend you remove all the "fluff" from the code before posting it. That means all the comments, logs, debugs and unused variables/methods. First of all it makes it easier for you to potentially spot your own mistakes and secondly it makes it easier and faster for people to help you on the forums :) .
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...
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!