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 -0.863 Tracking Error 0.193 Treynor Ratio 0 Total Fees $0.00 |
from QuantConnect import * class MultidimensionalOptimizedFlange(QCAlgorithm): def Initialize(self): # Set Start Date self.SetStartDate(2016, 6, 14) self.SetEndDate(2020, 8, 14) # Set Strategy Cash self.SetCash(100000) # Set Traded Equity self.AddEquity("SPY", Resolution.Minute) #Add Simple Moving Average and Bolinger Bands Indicators self.sma = self.SMA("SPY", 20, Resolution.Minute) self.bb = self.BB("SPY", 40, 2.0, MovingAverageType.Simple) def OnData(self, data): #Sets variable for strategy i = 0 #Gets current Market Price self.currpri = self.Securities["SPY"].Close #Checks if BB Indicator is ready if not self.bb.IsReady: return #Calculates BandWidth of BB Indicator self.BandWidth = ((self.bb.UpperBand.Current.Value-(self.bb.LowerBand.Current.Value))/(self.bb.MiddleBand.Current.Value)) #Check if SMA Indicator is ready if not self.sma.IsReady: return #Test if can trade if self.currpri > self.sma.Current.Value and self.BandWidth > 2: self.SetHoldings("SPY", 0.5) if self.currpri < self.sma.Current.Value and self.BandWidth > 2: self.SetHoldings("SPY", -0.5)