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 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class CasualApricotChicken(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 3, 20) self.SetEndDate(2022, 3, 20) 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)) 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] #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.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.LimitOrder(self.ticker, -self.quantity, self.price) def BarHandler(self, consolidated): return