| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -8.328 Tracking Error 0.115 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
import numpy as np
class rsi_loop(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 10, 10) #Set Start Date
self.SetEndDate(2021,10,18)
self.SetCash(100)
self.invested = 10
# Set deposits
#self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday),self.TimeRules.At(12,00),self.OnData)
# Set Brokerage Model
#self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
self.AddCrypto("BTCUSD", Resolution.Tick)
self.btcusd = self.AddCrypto("BTCUSD", Resolution.Minute)
RSI_period = 14
self.RSI_ind_BTC = self.RSI(self.btcusd.Symbol,RSI_period,Resolution.Minute)
self.SetWarmUp(RSI_period)
self.allowed_operations = 8
self.quantity = (self.Portfolio.Cash / self.allowed_operations)
self.portions = (self.Portfolio.Cash / self.allowed_operations) / self.Portfolio.Cash
#initializing variables
self.btc_longoper = True
# Create our rolling windows
#self.tradeBarWindow = RollingWindow[TradeBar](5) # Store the last 5 values
#self.rsiWindow = RollingWindow[Decimal](10) # Store the last 10 values
def OnData(self, data):
if not self.RSI_ind_BTC.IsReady:
return
if not self.Portfolio.Invested and self.RSI_ind_BTC.Current.Value < 28 and self.btc_longoper == True:
quantity = self.CalculateOrderQuantity(self.btcusd.Symbol, 0.5)
self.MarketOrder(self.btcusd.Symbol,quantity)
#self.SetHoldings(self.btcusd.Symbol,0.5)
self.Debug("RSI < 30, Buying")
self.btc_longoper = False
if self.btc_longoper == False and self.RSI_ind_BTC.Current.Value > 70:
self.Liquidate()
self.Plot("Indicators","RSI", self.RSI_ind_BTC.Current.Value)