Overall Statistics
Total Trades
24
Average Win
0.00%
Average Loss
0.00%
Compounding Annual Return
-0.012%
Drawdown
0.000%
Expectancy
0.588
Net Profit
-0.006%
Sharpe Ratio
-0.299
Probabilistic Sharpe Ratio
16.182%
Loss Rate
70%
Win Rate
30%
Profit-Loss Ratio
4.29
Alpha
0
Beta
-0.004
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.149
Tracking Error
0.079
Treynor Ratio
0.025
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 *


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 = self.EMA("EURUSD", 5, Resolution.Minute)
        self.RegisterIndicator("EURUSD", self.EMA5, timedelta(minutes=5))
        self.EMA40 = self.EMA("EURUSD", 40, Resolution.Minute)
        self.RegisterIndicator("EURUSD", self.EMA40, timedelta(minutes=5))
        self.SetBenchmark("EURUSD")
        self.SetWarmUp(55)
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Tuesday), self.TimeRules.At(6,0), self.SpecificTime)
    def OnData(self, data):
        if self.IsWarmingUp:
            return
            #self.SetHoldings("USDCAD", 50)
    
    def SpecificTime(self):
        self.Plot('Custom', 'EMA5', self.EMA5.Current.Value)
        self.Plot('Custom', 'EMA40', self.EMA40.Current.Value)
        if not self.Portfolio.Invested:
            close=self.Securities["EURUSD"].Close
            if self.EMA5.Current.Value>self.EMA40.Current.Value:
                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))
        #if self.Portfolio.Invested:
            #def OrderEvent(self, orderEvent):
                #allcancelledOrders=self.Transactions.CancelOpenOrders()