Overall Statistics |
Total Trades 1401 Average Win 0.35% Average Loss -0.20% Compounding Annual Return -18.476% Drawdown 36.600% Expectancy -0.250 Net Profit -18.580% Sharpe Ratio -0.657 Probabilistic Sharpe Ratio 2.490% Loss Rate 72% Win Rate 28% Profit-Loss Ratio 1.72 Alpha -0.173 Beta 0.196 Annual Standard Deviation 0.203 Annual Variance 0.041 Information Ratio -1.086 Tracking Error 0.31 Treynor Ratio -0.68 Total Fees $0.00 Estimated Strategy Capacity $39000.00 Lowest Capacity Asset XAUUSD 8I |
class EMAandSMACrossover1_5(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 2, 1) self.SetEndDate(2021, 2, 1) self.SetCash(100000) self.symbol = self.AddCfd("XAUUSD", Resolution.Minute, Market.Oanda).Symbol # Indicators self.sma = self.SMA(self.symbol, 100, Resolution.Hour) self.emaFast = self.EMA(self.symbol, 10, Resolution.Hour) self.emaNorm = self.EMA(self.symbol, 25, Resolution.Hour) self.emaSlow = self.EMA(self.symbol, 45, Resolution.Hour) # Market Tickets self.order = None self.sl = None self.tp = None # Financial Variables self.slPips = 2.5 self.tpPips = 6.0 self.slPrice = None self.tpPrice = None self.SetWarmUp(6000) def OnData(self, data): if not self.sma.IsReady: return price = self.Securities[self.symbol].Close quantity = self.CalculateOrderQuantity(self.symbol, 1.0) if not self.Portfolio.Invested: if self.sma.Current.Value < price: if self.emaFast.Current.Value > self.emaNorm.Current.Value and self.emaNorm.Current.Value > self.emaSlow.Current.Value: self.slPrice = price - self.slPips self.tpPrice = price + self.tpPips # Market Order self.order = self.MarketOrder(self.symbol, quantity) # SL and TP Orders self.sl = self.StopMarketOrder(self.symbol, -quantity, self.slPrice) self.tp = self.LimitOrder(self.symbol, -quantity, self.tpPrice) # Plot SL and TP self.Plot("Data Chart", "Asset Price", price) self.Plot("Data Chart", "Stop Loss", self.slPrice) self.Plot("Data Chart", "Take Profit", self.tpPrice) elif self.sma.Current.Value > price: if self.emaSlow.Current.Value > self.emaNorm.Current.Value and self.emaNorm.Current.Value > self.emaFast.Current.Value: self.slPrice = price + self.slPips self.tpPrice = price - self.tpPips # Market Order self.order = self.MarketOrder(self.symbol, -quantity) # SL and TP Orders self.sl = self.StopMarketOrder(self.symbol, quantity, self.slPrice) self.tp = self.LimitOrder(self.symbol, quantity, self.tpPrice) # Plot SL and TP self.Plot("Data Chart", "Asset Price", price) self.Plot("Data Chart", "Stop Loss", self.slPrice) self.Plot("Data Chart", "Take Profit", self.tpPrice) def OnOrderEvent(self, orderEvent): self.Log(orderEvent) if not (orderEvent.Status == OrderStatus.Filled): return if (self.tp is None) or (self.sl is None): return if self.tp.OrderId == orderEvent.OrderId: self.sl.Cancel() # Plot SL and TP self.Plot("Data Chart", "Stop Loss", self.slPrice) self.Plot("Data Chart", "Take Profit", self.tpPrice) return if self.sl.OrderId == orderEvent.OrderId: self.tp.Cancel() # Plot SL and TP self.Plot("Data Chart", "Stop Loss", self.slPrice) self.Plot("Data Chart", "Take Profit", self.tpPrice) return