Overall Statistics
Total Trades
3
Average Win
0.00%
Average Loss
0%
Compounding Annual Return
-0.002%
Drawdown
0.000%
Expectancy
0
Net Profit
-0.001%
Sharpe Ratio
-0.167
Probabilistic Sharpe Ratio
18.605%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0
Beta
-0.001
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.149
Tracking Error
0.079
Treynor Ratio
0.013
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.EMA40 = ExponentialMovingAverage(40)
        self.RegisterIndicator("EURUSD", self.EMA5, timedelta(minutes=5))
        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(4,0), self.SpecificTime)
        
    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)
        
        self.Plot("Diff", "EMA5-EMA40", self.EMA5.Current.Value - self.EMA40.Current.Value)
        
        self.Plot("Invested", "Invested", int(self.Portfolio.Invested))
        
        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))