Hello all,
If I am running an ema cross-over with stop loss (self.StopMarketOrder) and the stop loss gets hit, is there a way to tell it to wait until the next cross-over occurs instead of opening another order?
I only know how to re-enter the market after a certian number of days have passed, For example:
# Check that at least 14 days (~2 weeks) have passed since we last hit our limit order
if (self.Time - self.stopMarketFillTime).days < 14:
return
I would like to be able to re-enter the market on the next ema cross-over. Any ideas?
Thanks for reading.
Rahul Chowdhury
Hey Andres,
We can place a lock on trading until our condition for new trades has been met. We can do this with a boolean which keeps track of whether trading has been locked or not.
Here is a simple 200-50 Day EMA cross over strategy with a trailing stop loss which employs this locking mechanism.
Best
Rahul
Andrés M
Thank you for sharing an example Rahul Chowdhury
Two quick questions about deploying an algorithm live:
- If my self.SetCash is set to $10,000 and my account has $20,000... will the algorithm use my full amount of $20,000 or only $10,000? all my order sizes are set to be x1.0 the SetCash but I just want to make sure lol
- If for whatever reason, my account gets disconnected to the algorithm with an open trade... can I deploy again the algorithm and it will take into consideration the open trades? (as long as they are symbols that get used in the algorithm)
- Anything to avoid when using Interactive Brokers as the brokerage where all trades will be taking place?
Please let me know if you need clarification on any of the questions.
Thanks again!
Rahul Chowdhury
Hey Andres,
Andrés M
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!