I am trying to implement the following simple breakout strategy using the Framework Algorithm Insight abstraction:
for each asset
- If long position does not exist and today's close is higher than the highest close in the past 50 days, enter long position
- If long position exists and today's close is lower than the lowest close for past 25 days, exit long position
- if short position does not exist and today's close is lower than the lowest close in the past 50 days, enter short position
- if short position exists and today's close is higher than the highest close in the past 25 days,
insights = []
for asset in universe:
if not symbolData.LongPosition and symbolData.LongBreakout:
insights.append(Insight.Price(symbolData.Symbol, self.predictionInterval, InsightDirection.Up))
continue
if symbolData.LongPosition and symbolData.LongExit:
# exit long position above
#insights.append(Insight(????))
continue
if not symbolData.ShortPosition and symbolData.ShortBreakout:
insights.append(Insight.Price(symbolData.Symbol, self.predictionInterval, InsightDirection.Down))
continue
if symbolData.ShortPosition and symbolData.ShortExit:
# exit short position above
#insights.append(Insight(????))
continue
Rahul Chowdhury
Closed because question is duplicate of this thread, which has been answered.
Filib Uster
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!