Overall Statistics
Total Trades
111
Average Win
9.90%
Average Loss
-5.31%
Compounding Annual Return
18.076%
Drawdown
40.600%
Expectancy
0.406
Net Profit
154.384%
Sharpe Ratio
0.603
Probabilistic Sharpe Ratio
10.635%
Loss Rate
51%
Win Rate
49%
Profit-Loss Ratio
1.86
Alpha
0.145
Beta
0.211
Annual Standard Deviation
0.273
Annual Variance
0.075
Information Ratio
0.234
Tracking Error
0.303
Treynor Ratio
0.78
Total Fees
$0.00
Estimated Strategy Capacity
$1100000.00
Lowest Capacity Asset
ETHUSD XJ
Portfolio Turnover
2.65%
from AlgorithmImports import *

class TrendlineRSI(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetCash(10000)
        self.ticker=self.AddCrypto("ETHUSD", Resolution.Hour)
        self.rsi=self.RSI(self.ticker.Symbol, 14, Resolution.Hour)

        self.TREND=self.SMA(self.ticker.Symbol, 25, Resolution.Daily)
        self.SetWarmup(25)


    def OnData(self, data):
        if self.IsWarmingUp:
            return
        if not self.ticker.Price > self.TREND.Current.Value:
            return
        
        rsi_value=self.rsi.Current.Value 
        trade_quantity = int(self.Portfolio.Cash / self.ticker.Price)*0.5 

        if not self.Portfolio.Invested:
            if rsi_value>15 and rsi_value<20:
                self.MarketOrder(self.ticker.Symbol, trade_quantity)
                self.StopMarketOrder(self.ticker.Symbol, -trade_quantity, self.ticker.Price*0.9)
                self.entry_price=self.ticker.Price
       
        if self.Portfolio.Invested:
            if rsi_value>95:
                self.Liquidate()