Overall Statistics
Total Trades
128
Average Win
5.53%
Average Loss
-17.70%
Compounding Annual Return
-66.567%
Drawdown
100.000%
Expectancy
-0.599
Net Profit
-100.000%
Sharpe Ratio
0.043
Probabilistic Sharpe Ratio
0.002%
Loss Rate
69%
Win Rate
31%
Profit-Loss Ratio
0.31
Alpha
0.038
Beta
-0.745
Annual Standard Deviation
1.141
Annual Variance
1.301
Information Ratio
0.056
Tracking Error
1.146
Treynor Ratio
-0.066
Total Fees
$0.00
Estimated Strategy Capacity
$240000.00
Lowest Capacity Asset
EURUSD 8G
from AlgorithmImports import *
# endregion

class Strategy(QCAlgorithm):

    def Initialize(self):

        self.Pair_1 = "EURUSD"
        self.holdingDays = 1
        self.SetStartDate (2010, 1, 1) 
        self.SetEndDate(2022,7,1)
        self.SetCash(10000)  
        self.SetBrokerageModel(BrokerageName.OandaBrokerage)
        self.EURSEK = self.AddForex(self.Pair_1, Resolution.Daily, Market.Oanda)
        self.symbols = [self.Pair_1]
        self.prevPrices = { symbol : RollingWindow[QuoteBar](7) for symbol in self.symbols }
        self.ticketPair1 = None 

    def OnData(self,data):
      
        self.quantity_1 = self.CalculateOrderQuantity(self.Pair_1, 1)
        
        for symbol in self.symbols:
            if data.ContainsKey(symbol):
                self.prevPrices[symbol].Add( data[symbol] )

        if not all([ window.IsReady for window in self.prevPrices.values() ]):
            return
     
        Pair1_window = self.prevPrices[self.Pair_1]
        Pair1_1D = Pair1_window[1].Close
        Pair1_0D = Pair1_window[0].Close

        if self.ticketPair1 is not None and self.UtcTime < self.ticketPair1.Time + timedelta(days=(self.holdingDays)):
            return

        if self.ticketPair1 is None and self.Securities[self.Pair_1].Exchange.ExchangeOpen is True and Pair1_0D > Pair1_1D :
            self.ticketPair1 = self.MarketOrder(self.Pair_1, 1000 )
            stop_price = self.ticketPair1.AverageFillPrice * 0.99
            self.stop_loss_ticket = self.StopMarketOrder(self.Pair_1, -self.quantity_1, stop_price)
            self.price = self.ticketPair1.AverageFillPrice

        if self.ticketPair1 is not None and self.Securities[self.Pair_1].Exchange.ExchangeOpen is True and self.UtcTime >= self.ticketPair1.Time + timedelta(days = 4): 
            self.MarketOrder(self.ticketPair1.Symbol, -self.ticketPair1.Quantity)
            self.ticketPair1 = None