Hi everyone!

 

I'm building a strategy where I'll need to draw daily candles. Ideally I would like to plot daily candles where you see the max and low price of that day. Is that possible?

The strategy so far is like this:

 


from AlgorithmImports import *

### <summary>.
### The entire charting system of quantconnect is adaptable. You can adjust it to draw whatever you'd like.
### Charts can be stacked, or overlayed on each other. Series can be candles, lines or scatter plots.
### Even the default behaviours of QuantConnect can be overridden.
### </summary>
### <meta name="tag" content="charting" />
### <meta name="tag" content="adding charts" />
### <meta name="tag" content="series types" />
### <meta name="tag" content="plotting indicators" />
class CustomChartingAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2010,1,1)
        #self.SetEndDate(2017,1,8)
        self.SetCash(100000)
        self.instrument = "SPY"
        self.instrument_to_trade = self.AddEquity(self.instrument, Resolution.Minute)
        self.order_quantity = 100

        # In your initialize method:
        # Chart - Master Container for the Chart:
        stockPlot = Chart("Trade Plot")
        # On the Trade Plotter Chart we want 3 series: trades and price:

        stockPlot.AddSeries(Series("Price", SeriesType.Candle, 0))
        self.AddChart(stockPlot)
        
        self.numberOfTradesPerDay = 1 
     
        self.lowWindow = RollingWindow[float](3)
        self.highWindow  = RollingWindow[float](3)

        self.highNumber = 5000000000000
        self.storedPriceHigh = 0
        self.storedPriceLow = self.highNumber
        
        self.Schedule.On(self.DateRules.EveryDay("SPY"),self.TimeRules.BeforeMarketClose("SPY", 10),self.EveryDayBeforeMarketClose)


    def OnData(self, slice):
        if slice[self.instrument] is None: return

        
        self.lastPrice = slice[self.instrument].Close
        
        
        if self.lastPrice > self.storedPriceHigh:
            self.storedPriceHigh = self.lastPrice
        
        if self.lastPrice < self.storedPriceLow:
            self.storedPriceLow = self.lastPrice    
            
        
        if self.highWindow.IsReady and self.lowWindow.IsReady:
            
  
                if self.numberOfTradesPerDay > 0 : #max 1 trade per day  
                    
                            
                            if self.storedPriceLow > self.lowWindow[0] and self.lastPrice > self.highWindow[0]: #here there's the check that the current candle is "inside" yesterday's
                                self.ticket_buy = self.LimitOrder(self.instrument, self.order_quantity, self.highWindow[0])
                                self.numberOfTradesPerDay = self.numberOfTradesPerDay - 1
                            if self.storedPriceHigh < self.highWindow[0] and self.lastPrice < self.lowWindow[0]:    
                                self.ticket_sell = self.LimitOrder(self.instrument, -self.order_quantity, self.lowWindow[0])
                                self.numberOfTradesPerDay = self.numberOfTradesPerDay - 1
                
    def EveryDayBeforeMarketClose(self):
        self.Liquidate("SPY")
        

    def OnEndOfDay(self, symbol):
       #Log the end of day prices:
       self.Plot("Trade Plot", "Price", self.lastPrice)
       self.lowWindow.Add(self.storedPriceLow)
       self.highWindow.Add(self.storedPriceHigh)
       self.storedPriceHigh = 0
       self.storedPriceLow = self.highNumber
       self.numberOfTradesPerDay = 1
       
    '''   
    def OnStartOfDay(self, symbol):
       #Log the end of day prices:
       #self.Plot("Trade Plot", "Price", self.lastPrice)
       pass
    '''