Hello :]
How can I create a strat that buys a stock immediately when the market opens and sells at the end of the day? The strat should receive the previous day ohlc, and the current day open to decide what to buy. selling will occur automatically at the end of the day.
Thanks 💰💰💰
Nico Xenox
Hey Super Richman,
take a look at scheduled events and rollling windows.
To close all the positions before market close you could do something like this:
For the ohlc you can either use rolling windows or just simply save the last closing value as a variable and call it the next morning.
Hope it helps ;)
Super Richman
Hi Nico Xenox thanks for the reply!
I couldn't find a way to get the current price of the asset from within the Rebalance function :[ you have any ideas?
Nico Xenox
Hey Super Richman,
please attach your backtest for further assistance.
Â
Best,
Nico
Super Richman
😊
Nico Xenox
Hey Super Richman,
Tbh I don't know a lot of c# but here should be a working version. For testing and learning you could take a look at the numerous algos written by QC on GitHub:
Â
If you're satisfied with my answer please dont forget to like and close this thread 😊
Hope it helps ;)
Super Richman
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!