Overall Statistics
Total Trades
82
Average Win
0.03%
Average Loss
-0.01%
Compounding Annual Return
-19.602%
Drawdown
2.400%
Expectancy
0.581
Net Profit
-1.760%
Sharpe Ratio
-5.534
Probabilistic Sharpe Ratio
0.329%
Loss Rate
48%
Win Rate
52%
Profit-Loss Ratio
2.02
Alpha
-0.135
Beta
-0.08
Annual Standard Deviation
0.028
Annual Variance
0.001
Information Ratio
-4.951
Tracking Error
0.084
Treynor Ratio
1.945
Total Fees
$0.00
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

class WarmupHistoryAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
        self.SetStartDate(2014,5,1)   #Set Start Date
        self.SetEndDate(2014,5,30)     #Set End Date
        self.SetCash(100000)          #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        forex = self.AddForex("EURUSD", Resolution.Minute, Market.Oanda) #Market.FXCM
        # forex = self.AddForex("EURUSD", Resolution.Second)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage) #InteractiveBrokersBrokerage, OandaBrokerage, Bitfinex, GDAX or FxcmBrokerage

        self.window = RollingWindow[QuoteBar](20) #https://www.quantconnect.com/docs/algorithm-reference/handling-data#Handling-Data-QuoteBars
    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
        if data.ContainsKey("EURUSD"):
            self.window.Add(data["EURUSD"])
        if not self.window.IsReady: return

        epsilon = 0.0001
        currBar = self.window[0]                     # Current bar had index zero.
        pastBar = self.window[19]                     # Past bar has index one.
        delta = epsilon * 10 
        if  currBar.Open - pastBar.Open < delta:
            self.current = self.Time
            # start = self.Time
            self.Debug(currBar.Open - pastBar.Open)#, str(self.current)) # self.Log (only in log files)
            self.SetHoldings("EURUSD", 1)
        if (self.Time - self.current).total_seconds() >= 60*60: # loss
            self.Debug('loss') #, currBar.Open - pastBar.Open) #, (self.Time - self.current).total_seconds())
            self.SetHoldings("EURUSD", -1) #self.Liquidate()
        if self.Portfolio["EURUSD"].UnrealizedProfit > 15:
            self.Debug('win') #, currBar.Open - pastBar.Open) #, (self.Time - self.current).total_seconds())
            self.SetHoldings("EURUSD", -1) #self.Liquidate()