Overall Statistics
Total Trades
7
Average Win
13.10%
Average Loss
0%
Compounding Annual Return
8.211%
Drawdown
13.600%
Expectancy
0
Net Profit
53.623%
Sharpe Ratio
0.703
Probabilistic Sharpe Ratio
19.364%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.03
Beta
0.22
Annual Standard Deviation
0.085
Annual Variance
0.007
Information Ratio
-0.527
Tracking Error
0.142
Treynor Ratio
0.272
Total Fees
$231.01
Estimated Strategy Capacity
$40000000.00
Lowest Capacity Asset
QQQ RIWIV7K5Z9LX
# Trading QC Engulfing Candlestick Pattern consolidated

from QuantConnect.Indicators.CandlestickPatterns import Engulfing

# ---------------------------------
STOCK = 'QQQ'; BAR = 15; LEV = 1.0;
# ---------------------------------

class CandlestickPattern(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2016, 6, 24)
        self.SetEndDate(2021, 11, 30)
        self.SetCash(1000000)
        res = Resolution.Minute
        self.stock = self.AddEquity(STOCK, res).Symbol
        self.SetWarmUp(4*BAR, res)
        self.pattern = Engulfing()
        consolidator = TradeBarConsolidator(timedelta(BAR))
        consolidator.DataConsolidated += self.consolidation_handler
        self.RegisterIndicator(self.stock, self.pattern, consolidator)


    def consolidation_handler(self, sender, consolidated):
        if self.IsWarmingUp  or not self.pattern.IsReady: return
    
        pattern = self.pattern.Current.Value
        
        self.Plot(self.stock, 'Engulfing', self.pattern.Current.Value)
        
        if pattern == 1:
            self.SetHoldings(self.stock, LEV)
            
        elif pattern == -1:
             self.Liquidate(self.stock)