Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-75.012%
Drawdown
5.200%
Expectancy
0
Net Profit
-4.699%
Sharpe Ratio
-3.453
Probabilistic Sharpe Ratio
10.814%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.03
Beta
1.025
Annual Standard Deviation
0.183
Annual Variance
0.033
Information Ratio
-1.71
Tracking Error
0.026
Treynor Ratio
-0.615
Total Fees
$1.00
Estimated Strategy Capacity
$56000000.00
Lowest Capacity Asset
QQQ RIWIV7K5Z9LX
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Market import TradeBar


# David Eldringhoff RSI Slope  fixed by Vladimir

# -----------------------------------------------------------
STOCK = 'QQQ'; BAR = 5; RSI_PERIOD = 14; MA = 14; DELAY = 1; FAST = 12; SLOW = 26
# -----------------------------------------------------------

class RSI_Slope(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021,11,20)  
        self.SetEndDate(datetime.now())  
        self.SetCash(25000) 
        self.SetBenchmark("QQQ")
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
        
        self.AddEquity("QQQ", Resolution.Minute)
        self.AddEquity("PSQ", Resolution.Minute)
        
        
        self.SetWarmUp(300, Resolution.Minute) 
        
        consolidator = TradeBarConsolidator(timedelta(minutes = BAR))
        consolidator.DataConsolidated += self.thirtyMinuteBarHandler
        self.rsi = RelativeStrengthIndex(RSI_PERIOD)
        self.qqqMACD = MovingAverageConvergenceDivergence(FAST, SLOW, 9, MovingAverageType.Exponential)
        
        self.RegisterIndicator("QQQ", self.rsi, consolidator)
        self.RegisterIndicator("QQQ", self.qqqMACD, consolidator)
        
        self.sma_rsi = IndicatorExtensions.SMA(self.rsi, MA) 
        self.sma_rsi_past = IndicatorExtensions.Of(Delay(DELAY), self.sma_rsi)
        self.rsi_slope = IndicatorExtensions.Minus(self.sma_rsi, self.sma_rsi_past)
        

    def thirtyMinuteBarHandler(self, sender, consolidated):
        if self.IsWarmingUp or not self.rsi_slope.IsReady: return 

        self.Plot('RSI SLOPE', 'rsi_slope', self.rsi_slope.Current.Value) 
        self.Plot('RSI SLOPE', 'zero', 0) 
        
        qqqMACDfast = self.qqqMACD.Fast.Current.Value
        qqqMACDslow = self.qqqMACD.Slow.Current.Value
        qqqMACDline = self.qqqMACD.Current.Value
        qqqsignalline = self.qqqMACD.Signal.Current.Value
        qqqMACDHistgram = self.qqqMACD.Histogram.Current.Value
        
        qqqrsislope = self.rsi_slope.Current.Value
    
        self.Log("qqqrsislope: {0}, Histogram {1}".format(qqqrsislope, qqqMACDHistgram))
        
        if not self.Portfolio["QQQ"].Invested and qqqrsislope > 0:
            self.SetHoldings("QQQ", 1)