The only way Ive been able to make it execute multiple trades is by switching it to
if self.Portfolio.Invested:
blah blah blah
if self.Portfolio invested
blah blah blah
if NOT self.Portfolio invested:
self.SetHoldings(sym, .001)
(basically just a way to get a very first trade and will remail invested ever since, hence the main entry commands beig if already invested.)
I obviously need help with my exit strategy and I feel like it has to do with price skipping over the exact baseline value. any help would be greatly appreciated, I'm super new to coding and could use any insights you all have. Thank you!
Derek Melchin
Hi Joshua,
To fix the issue of the price skipping over the baseline, we can replace
if self.Securities["AUDNZD"].Price == self.baseline.Current.Value
with
if self.Securities["AUDNZD"].Price <= self.baseline.Current.Value
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.
Joshua Hughes
Thank you for the reply! but wouldnt that just take me out of all shorts immediately?
Derek Melchin
Hi Joshua,
Not necessarily, since the entry and exit conditions are different. If we flip the exit condition to
if self.Securities["AUDNZD"].Price >= self.baseline.Current.Value:
we see the short trades are held for a longer period of time.
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.
Joshua Hughes
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!