Overall Statistics |
Total Trades 45 Average Win 0.46% Average Loss -0.51% Compounding Annual Return -31.273% Drawdown 11.800% Expectancy -0.567 Net Profit -5.882% Sharpe Ratio -1.188 Probabilistic Sharpe Ratio 11.831% Loss Rate 77% Win Rate 23% Profit-Loss Ratio 0.91 Alpha -0.238 Beta 0.112 Annual Standard Deviation 0.184 Annual Variance 0.034 Information Ratio -1.814 Tracking Error 0.218 Treynor Ratio -1.952 Total Fees $0.00 Estimated Strategy Capacity $850000.00 Lowest Capacity Asset GBPUSD 8G |
#region imports from AlgorithmImports import * from decimal import * from datetime import timedelta #endregion class LogicalApricotFrog(QCAlgorithm): def Initialize(self): self.SetTimeZone(TimeZones.London) # Timezone set to GMT - logs will be in GMT self.SetStartDate(2023, 1, 1) self.SetEndDate(2023, 3, 1) self.SetCash(10000) self.symbol = self.AddForex("GBPUSD", Resolution.Hour, Market.Oanda).Symbol self.fast = self.SMA(self.symbol, int(self.GetParameter('SmaFast')), Resolution.Hour) self.slow = self.SMA(self.symbol, int(self.GetParameter('SmaSlow')), Resolution.Hour) self.SetWarmUp(50) self.fastValues = RollingWindow[float](2) self.slowValues = RollingWindow[float](2) def OnData(self, data): self.fastValues.Add(self.fast.Current.Value) self.slowValues.Add(self.slow.Current.Value) if self.IsWarmingUp: return past_fast_SMA = self.fastValues[1] past_slow_SMA = self.slowValues[1] fast_SMA = self.fast.Current.Value slow_SMA = self.slow.Current.Value if self.fastValues.IsReady and self.slowValues.IsReady: if (fast_SMA > slow_SMA) and (past_fast_SMA < past_slow_SMA): self.MarketOrder(self.symbol, (10000)) self.LimitOrder(self.symbol, (-10000), data[self.symbol].Close + 0.0050) self.StopMarketOrder(self.symbol, (-10000), data[self.symbol].Close - 0.0020) self.Log('########### LONG #################') self.Log("Time >> {0}".format(self.Time)) self.Log('If (fastEMA > slowEMA) & (pastFastEma < pastSlowEma):') self.Log("pastFastEma >> {0}".format(self.fastValues[1])) self.Log("pastSlowEma >> {0}".format(self.slowValues[1])) self.Log("Current fast_EMA >> {0}".format(self.fast.Current.Value)) self.Log("Current slow_EMA >> {0}".format(self.slow.Current.Value)) self.Log("Long @ >> {0}".format(self.Securities[self.symbol].Price)) self.Log('Limit @ >> {0}'.format((self.Securities[self.symbol].Price) + 0.0050)) self.Log('Stop @ >> {0}'.format((self.Securities[self.symbol].Price) - 0.0020)) def OnOrderEvent(self, orderEvent): order = self.Transactions.GetOrderById(orderEvent.OrderId) if order.Status == OrderStatus.Filled: if order.Type == OrderType.Limit or OrderType.StopMarket: self.Transactions.CancelOpenOrders(order.Symbol) if order.Status == OrderStatus.Canceled: self.Log(str(orderEvent))