I am scheduling 2 events: First for indicator signal before trade and the 2nd for actual trade after market opens.
Kindly need your help in updating my daily indicators before market open. These are daily indicators that should be available on Day Close and I need them the following morning before trade.
What is the simplest way to just "refresh" or update the Indicators in the first scheduled event? You can see the simple code attached.
TY
Vncne
Hey
OnData is run every time the algorithm receives new data, so I moved the "updating" of indicator values there. I also changed the resolution of your QQQ to daily so OnData is only run once a day every time it updates the variables you created with new values. Is this what you were trying to do?
Yanki Margalit
Thnaks for the answer.
The issue I se with your implementation is that you execute orders on Stale prices from the day before. On the one hand - I need to gather daily indicator data before trade and on the other hand I need to excecute orders on valid prices after market open.
If you view the orders in the back test you have provided - prices are stale. I guess this is whuy I used the minute reslotion. Anyway I will explore futrther. TY
Yanki Margalit
One more key issue - It seems that the way uou implemented it - The indicator is not updated before market open. Only after market open the previous day indicators are calciulated, so I get a 1 day delay.
Derek Melchin
Hi Yanki,
When we subscribe to minute data, daily indicators are updated after the first bar for a new day is received by the algorithm. See the attached backtest logs for reference.
To have the indicators update at 8AM, one solution is to subscribe to pre-market data. This can be done with
self.QQQ = self.AddEquity("QQQ", Resolution.Minute, Market.USA, False, 1, True).Symbol
However, this will cause the indicators to be updated with extended market hours bars instead of the daily bars from regular trading hours. To overcome this issue, we can create a custom consolidation period. Refer to this related thread.
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.
Yanki Margalit
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!