| Overall Statistics |
|
Total Trades 3206 Average Win 1.14% Average Loss -0.20% Compounding Annual Return 2.600% Drawdown 24.900% Expectancy 0.056 Net Profit 13.701% Sharpe Ratio 0.199 Probabilistic Sharpe Ratio 1.471% Loss Rate 84% Win Rate 16% Profit-Loss Ratio 5.77 Alpha 0.057 Beta -0.213 Annual Standard Deviation 0.14 Annual Variance 0.02 Information Ratio -0.469 Tracking Error 0.234 Treynor Ratio -0.13 Total Fees $8568.55 Estimated Strategy Capacity $13000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class PriceCrossingEMA(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 1, 1)
self.SetEndDate(2021, 12, 31)
self.SetCash(100000)
self.symbol = self.AddEquity("QQQ", Resolution.Minute).Symbol
consolidator = TradeBarConsolidator(timedelta(minutes = 5))
self.Consolidate(self.symbol, timedelta(minutes=5), self.BarHandler)
self.emaShort = ExponentialMovingAverage(50)
self.RegisterIndicator(self.symbol, self.emaShort, consolidator)
self.emaLong = ExponentialMovingAverage(200)
self.RegisterIndicator(self.symbol, self.emaLong, consolidator)
self.SetWarmUp(5*5*200, Resolution.Minute)
def BarHandler(self, consolidated):
if self.IsWarmingUp: return
if not self.emaLong.IsReady: return
ema_f = self.emaShort.Current.Value
ema_s = self.emaLong.Current.Value
C = self.Securities[self.symbol].Close
if not self.Portfolio.Invested:
if ema_s > C > ema_f:
self.SetHoldings(self.symbol, -1, False, " ema_s > C > ema_f")
elif ema_s < C < ema_f:
self.SetHoldings(self.symbol, 1, False, " ema_s < C < ema_f")
if self.Portfolio[self.symbol].IsShort:
if C > ema_s:
self.Liquidate(self.symbol, " C > ema_s")
elif self.Portfolio[self.symbol].IsLong:
if C < ema_s:
self.Liquidate(self.symbol, "C < ema_s ")