Overall Statistics |
Total Trades 78 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 Tracking Error 0 Treynor Ratio 0 Total Fees $78.00 Estimated Strategy Capacity $5500000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
#region imports from AlgorithmImports import * #endregion class CasualApricotChicken(QCAlgorithm): def Initialize(self): # March 20 is a Sunday #self.SetStartDate(2022, 3, 20) self.SetStartDate(2022, 3, 18) self.SetEndDate(2022, 3, 18) self.SetCash(25000) #self.stopLossBuffer = 0.05 #self.takeProfitPercentage = 0.005 self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) self.ticker = self.AddEquity("QQQ", Resolution.Minute).Symbol #self.Consolidate(self.ticker, timedelta(minutes=5), self.BarHandler) self.window = RollingWindow[TradeBar](4) #self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.015)) self.yes = '-=\u2261 \U0001F44D \u2261=-' self.no = '-=\u2261 \U0001F44E \u2261=-' def OnData(self, data): self.window.Add(data[self.ticker]) if not self.window.IsReady: return #3bar reversal trade tickD = self.window[0] tickC = self.window[1] tickB = self.window[2] tickA = self.window[3] self.Log(f"tickA: {tickA.Close} - tickB: {tickB.Close} - tickC: {tickC.Close} - tickD: {tickD.Close}") self.Log(f"Condition to invest is: {self.yes if not self.Portfolio.Invested and (tickA.Close > tickB.Close) and (tickB.Close > tickC.Close) and (tickC.Close < tickD.Close) else self.no}") self.Log(f"Condition to liquidate is: {self.yes if self.Portfolio.Invested and self.Portfolio[self.ticker].Price >= self.takeProfitPrice else self.no}") #downtrend reveral (long positioning) if not self.Portfolio.Invested and (tickA.Close > tickB.Close) and (tickB.Close > tickC.Close) and (tickC.Close < tickD.Close): self.SetHoldings(self.ticker, 1) self.quantity = -self.Portfolio[self.ticker].Quantity self.stopMarketPrice = tickC.Low self.StopMarketOrder(self.ticker, self.quantity, self.stopMarketPrice) self.takeProfitPrice = tickA.High self.Log(f"We are invested! Qty: {-self.quantity}, StopMarketPrice: {self.stopMarketPrice}, TakeProfitPrice: {self.takeProfitPrice}") #self.takeProfitPrice = self.Portfolio[self.ticker].Price * (1 + self.takeProfitPercentage) elif self.Portfolio.Invested and self.Portfolio[self.ticker].Price >= self.takeProfitPrice: self.Transactions.CancelOpenOrders() self.Liquidate() self.Log("We have liquidated.") #self.LimitOrder(self.ticker, -self.quantity, self.price) #def BarHandler(self, consolidated): # return