Overall Statistics |
Total Trades 462 Average Win 1.45% Average Loss -0.70% Compounding Annual Return 37.337% Drawdown 12.200% Expectancy 0.189 Net Profit 88.725% Sharpe Ratio 1.435 Probabilistic Sharpe Ratio 67.774% Loss Rate 61% Win Rate 39% Profit-Loss Ratio 2.06 Alpha 0.264 Beta 0.011 Annual Standard Deviation 0.184 Annual Variance 0.034 Information Ratio 0.724 Tracking Error 0.235 Treynor Ratio 24.594 Total Fees $3923.35 Estimated Strategy Capacity $23000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
# super trend master from AlgorithmImports import * # ------------------------------------------------------------------------- STOCK = "QQQ"; BAR = 201; SL = -0.0145; TP = 0.005; ATR = 14; MULT = 0.165; # ------------------------------------------------------------------------- class SuperTrendIndicator(QCAlgorithm): def Initialize(self): self.SetStartDate(DateTime(2020, 6, 10, 9, 30, 0)) self.SetEndDate(DateTime(2022, 6, 10, 16, 0, 0)) self.SetCash(200000) res = Resolution.Minute self.stock = self.AddEquity(STOCK, res).Symbol consolidator = TradeBarConsolidator(timedelta(minutes = BAR)) self.Consolidate(self.stock, timedelta(minutes = BAR), self.BarHandler) self.st = SuperTrend(ATR, MULT, MovingAverageType.Wilders) self.RegisterIndicator(self.stock, self.st, consolidator) self.SetWarmUp(5*BAR*ATR, res) def BarHandler(self, consolidated): if self.IsWarmingUp: return if not self.st.IsReady: return self.Plot(STOCK, "Price", self.Securities[self.stock].Price) self.Plot(STOCK, "Super Trend", self.st.Current.Value) pnl = self.Securities[self.stock].Holdings.UnrealizedProfitPercent if not self.Portfolio[self.stock].IsLong: if self.Securities[self.stock].High > self.st.Current.Value: self.SetHoldings(self.stock, 1, True, "Buy Signal") elif not self.Portfolio[self.stock].IsShort: if self.Securities[self.stock].Low < self.st.Current.Value: self.SetHoldings(self.stock, -1, True, "Sell Signal") elif self.Portfolio[self.stock].Invested: if pnl < SL: self.Liquidate(self.stock, "Stop Loss") elif pnl > TP: self.Liquidate(self.stock, "Take Profit")