Overall Statistics
Total Trades
583
Average Win
5.30%
Average Loss
-1.92%
Compounding Annual Return
116.767%
Drawdown
65.400%
Expectancy
0.671
Net Profit
4942.781%
Sharpe Ratio
1.857
Probabilistic Sharpe Ratio
81.465%
Loss Rate
56%
Win Rate
44%
Profit-Loss Ratio
2.76
Alpha
0.639
Beta
1.538
Annual Standard Deviation
0.499
Annual Variance
0.249
Information Ratio
1.757
Tracking Error
0.421
Treynor Ratio
0.602
Total Fees
$111787.81
Estimated Strategy Capacity
$12000000.00
Lowest Capacity Asset
TQQQ UK280CGTCB51
class PriceActionTQQQ(QCAlgorithm):
    
    def Initialize(self):
        
        self.SetStartDate(2017, 1, 1)  
        self.SetCash(100000)  
        self.TQQQ = self.AddEquity("TQQQ", Resolution.Minute).Symbol  
        self.SetBenchmark("QQQ")
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
        self.SetExecution(ImmediateExecutionModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        
        symbol = [Symbol.Create(self.TQQQ, SecurityType.Equity, Market.USA)]
        self.AddUniverseSelection(ManualUniverseSelectionModel(symbol))
        
        self.AddAlpha(PriceActionTQQQAlphaModel(self, self.TQQQ))
        
        self.SetRiskManagement(MaximumDrawdownPercentPortfolio(0.045))
        
class PriceActionTQQQAlphaModel(AlphaModel):
    
    def __init__(self, algorithm, tkr):
        self.period = timedelta(days=1)
        self.symbol = tkr
        self.symbolData = SymbolData(algorithm)
    
    def Update(self, algorithm, data):
        insights = []
        
        HO = 0.0
        OL = 0.0
        
        if self.symbolData.Updated:
            Open  = self.symbolData.open
            High  = self.symbolData.high
            Low   = self.symbolData.low
            Close = self.symbolData.close
            
            HO = High -  Open
            OL = Open - Low
            HC = High - Close
            CL = Close - Low
            
            if Close > Open:
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                
            if Close < Open:
                if HO < OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None))
                if HO == OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                    
            if Close == Open:
                if HO < OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None))
                if HO == OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Flat, 1, None))
                    
            self.symbolData.Updated = False
                
        return insights
        
    def OnSecuritiesChanged(self, algorithm, changes):
        self.changes =  changes
        
    
class SymbolData:
    
    def __init__(self, algorithm):
        algorithm.Consolidate("TQQQ", Resolution.Daily, self.DailyBarHandler)
        
        self.open = 0
        self.close = 0
        self.high = 0
        self.low = 0
        self.Updated = False
        
        
    def DailyBarHandler(self, consolidated):
        self.open = consolidated.Open
        self.close = consolidated.Close
        self.high = consolidated.High
        self.low = consolidated.Low
        self.Updated = True