Hi, I am new to quantconnect. The following codes work perfectly under hour and minute resolution, but the chart is not showing under daily resolution. Anyone know why? Thanks.
from AlgorithmImports import *
class SimpleMovingAveragePatternAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2023, 6, 1)
self.SetEndDate(2023, 8, 25)
self.SetCash(100000)
self.resol = Resolution.Hour
self.equity = self.AddEquity("AAPL", self.resol, dataNormalizationMode=DataNormalizationMode.Raw)
self.symbol = self.equity.Symbol
chart = Chart("Candlestick")
self.AddChart(chart)
chart.AddSeries(CandlestickSeries(self.symbol, "$"))
def OnData(self, data):
# chart
if not data.ContainsKey(self.symbol):
return
if self.IsMarketOpen(self.symbol):
self.Plot("Candlestick", self.symbol, data[self.symbol])
Mia Alissi
The issue you're experiencing might be due to the way data is handled at different resolutions in QuantConnect. When you're using the Daily resolution, the
OnData
method is only called once per day at the end of the trading day. This means that the candlestick for the current trading day is not fully formed yet and hence might not be plotted.However, when you're using Hour or Minute resolution, the
OnData
method is called multiple times throughout the trading day, allowing the candlestick to be updated and plotted in real-time.Here is an example of how to plot a daily candlestick chart:
In this example, the
OnEndOfDay
method is used to plot the data. This method is called at the end of each trading day, which is when the daily bar is fully formed and ready to be plotted.For more information, you can refer to the QuantConnect Documentation.
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.
Steven Lai
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!