Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-11.277%
Drawdown
14.700%
Expectancy
0
Net Profit
-2.012%
Sharpe Ratio
-0.044
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
1.025
Beta
-54.928
Annual Standard Deviation
0.445
Annual Variance
0.198
Information Ratio
-0.086
Tracking Error
0.446
Treynor Ratio
0
Total Fees
$1.00
class RSIalgo(QCAlgorithm):
    
    def Initialize(self):
        # Define a date range and strating capital for backtest
        self.SetStartDate(2018, 6, 24)  # Backtest starting date
        self.SetEndDate(2018, 8, 24)  # Last date = Today
        self.SetCash(10000)  # Define the initial capital
        
        # Select the stock to trade
        self.tesla = self.AddEquity("TSLA", Resolution.Daily)
        # Calling the RSI
        self.rsi = self.RSI("TSLA", 14)
        
                
                
    def OnData(self, data):
        # If we are not invest in TSLA and RSI is above 51 and below 60, go Long
        if not self.Portfolio["TSLA"].Invested:
            if self.rsi.Current.Value > 51 and self.rsi.Current.Value < 60:
                self.MarketOrder("TSLA", 22)
        if self.rsi.Current.Value > 80:
            self.Liquidate()