Overall Statistics
Total Trades
455
Average Win
2.26%
Average Loss
-1.19%
Compounding Annual Return
93.118%
Drawdown
14.900%
Expectancy
0.590
Net Profit
364.672%
Sharpe Ratio
3.045
Probabilistic Sharpe Ratio
99.498%
Loss Rate
45%
Win Rate
55%
Profit-Loss Ratio
1.90
Alpha
0.578
Beta
0.235
Annual Standard Deviation
0.198
Annual Variance
0.039
Information Ratio
1.99
Tracking Error
0.249
Treynor Ratio
2.567
Total Fees
$219.70
Estimated Strategy Capacity
$1600000.00
Lowest Capacity Asset
ETHUSD XJ
# RSI for equities, cryptos and cfds with Stop Loss and Take Profit
# ------------------------------------------------------------------------------
EQUITIES = ['AAPL','TSLA']; CRYPTOS = ['BTCUSD', 'ETHUSD']; CFDS = ['WTICOUSD']; 
RSI_PERIOD = 14; SL = -0.05; TP = 0.10;
# ------------------------------------------------------------------------------

class IndicatorForEquitiesAndCryptos(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1) 
        self.SetEndDate(2022, 5, 1) 
        self.SetCash(100000)
        self.equities = [self.AddEquity(ticker, Resolution.Minute).Symbol for ticker in EQUITIES]
        self.cryptos = [self.AddCrypto(ticker, Resolution.Minute).Symbol for ticker in CRYPTOS]
        self.cfds = [self.AddCfd(ticker, Resolution.Minute).Symbol for ticker in CFDS]
        self.assets = self.equities + self.cryptos + self.cfds
        self.rsi = {}
        for sec in self.assets:
            self.rsi[sec] = self.RSI(sec, RSI_PERIOD, MovingAverageType.Simple, Resolution.Daily)
        self.SetWarmUp(RSI_PERIOD + 1, Resolution.Daily)
        

    def OnData(self, data):
        if not (self.Time.hour == 10 and self.Time.minute == 1): return
        if self.IsWarmingUp: return
        # self.Log(self.assets)

        for sec in self.assets:
            rsi = self.rsi[sec].Current.Value
            self.Plot("RSI", sec, rsi)
            if not self.Portfolio[sec].Invested:
                if rsi >= 60:
                    self.SetHoldings(sec, 0.2) 

            elif self.Portfolio[sec].Invested:
                pnl = self.Securities[sec].Holdings.UnrealizedProfitPercent
                if rsi < 50:
                    self.Liquidate(sec, "rsi < 50")
                elif pnl < SL:
                    self.Liquidate(sec, "Stop Loss")
                elif pnl > TP:
                    self.Liquidate(sec, "Take Profit")