Overall Statistics |
Total Trades 198 Average Win 0.00% Average Loss 0.00% Compounding Annual Return -0.003% Drawdown 0.000% Expectancy -0.631 Net Profit -0.001% Sharpe Ratio -5.045 Probabilistic Sharpe Ratio 0.000% Loss Rate 90% Win Rate 10% Profit-Loss Ratio 2.65 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.149 Tracking Error 0.079 Treynor Ratio -2.941 Total Fees $0.00 |
from Alphas.EmaCrossAlphaModel import EmaCrossAlphaModel from datetime import datetime,timedelta import numpy as np from System.Collections.Generic import List from QuantConnect.Data.UniverseSelection import* from System import * from QuantConnect.Indicators import ExponentialMovingAverage class ScheduledEventsAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetEndDate(2020, 6, 22) # Set end date self.SetCash(100000000) # Set Strategy Cash self.forex = self.AddForex("EURUSD", Resolution.Minute, Market.Oanda) self.SetBrokerageModel(BrokerageName.OandaBrokerage) self.EMA5 = ExponentialMovingAverage(5) self.RegisterIndicator("EURUSD", self.EMA5, timedelta(minutes=5)) self.EMA40 = ExponentialMovingAverage(40) self.RegisterIndicator("EURUSD", self.EMA40, timedelta(minutes=5)) self.SetBenchmark("EURUSD") self.SetWarmUp(55) self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday), self.TimeRules.At(6,0), self.SpecificTime) self.marketTicket=None self.stopLimitTicket=None self.stopMarketTicket=None def OnData(self, data): if self.IsWarmingUp: return def SpecificTime(self): self.Plot('Custom', 'EMA5', self.EMA5.Current.Value) self.Plot('Custom', 'EMA40', self.EMA40.Current.Value) close=self.Securities["EURUSD"].Close if self.marketTicket==None: if self.EMA5.Current.Value<self.EMA40.Current.Value: self.marketTicket=self.MarketOrder("EURUSD", 100000) self.stopLimitTicket = self.LimitOrder("EURUSD", -100000, (close+0.0011)) self.stopMarketTicket = self.StopMarketOrder("EURUSD", -100000, (close-0.0005)) if self.EMA5.Current.Value<self.EMA40.Current.Value: self.MarketOrder("EURUSD", -100000) self.stopLimitTicket = self.LimitOrder("EURUSD", 100000, (close-0.0011)) self.stopMarketTicekt = self.StopMarketOrder("EURUSD", 100000, (close+0.0005)) def OnOrderEvent(self, orderEvent): if self.stopLimitTicket !=None and self.stopLimitTicket.OrderId == orderEvent.OrderId: self.stopMarketTicket.Cancel() self.marketTicket=None allCancelledOrders=self.Transactions.CancelOpenOrders() self.Liquidate() if self.stopMarketTicket !=None and self.stopMarketTicket.OrderId == orderEvent.OrderId: self.stopLimitTicket.Cancel() self.marketTicket=None allCancelledOrders=self.Transactions.CancelOpenOrders() self.Liquidate