Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
class WarmupHistoryConsolidated(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(2020, 9, 8)
        self.SetEndDate(2020, 9, 8)
        self.SetCash(1000)          #Set Strategy Cash
        self.invested = False
       
        forex = self.AddForex("EURUSD", Resolution.Minute) # I want incorporate minute data in the algorithm. Not just hourly.
        
        self.fiveMinuteTradeBarWindow = RollingWindow[QuoteBar](5)
        self.Consolidate("EURUSD", timedelta(minutes=5), self.FiveMinuteBarHandler)
        
        self.oneHourTradeBarWindow = RollingWindow[QuoteBar](5)
        self.Consolidate("EURUSD", timedelta(minutes=60), self.OneHourBarHandler)
        
        self.SmaHigh = SimpleMovingAverage(10)
        self.SmaHighWindow = RollingWindow[float](5)
        self.SmaHigh.Updated += self.SmaHighUpdated

        self.RegisterIndicator("EURUSD", self.SmaHigh, Resolution.Hour)
        
        # history = self.History(["EURUSD"], (60 * 10) + 60)

        # prints out the tail of the dataframe
        # self.Log(str(history.loc["EURUSD"].tail()))

        # for index, row in history.loc["EURUSD"].iterrows():
        #     self.SmaHigh.Update(index, row["high"])
        
        self.SetWarmUp(10, Resolution.Hour)
        
    def SmaHighUpdated(self, sender, updated):
        self.SmaHighWindow.Add(updated.Value)
        
    def FiveMinuteBarHandler(self, consolidated):
        self.fiveMinuteTradeBarWindow.Add(consolidated)
        
    def OneHourBarHandler(self, consolidated):
        self.oneHourTradeBarWindow.Add(consolidated)
        self.Log("Last hour close: " + str(self.oneHourTradeBarWindow[0].Value))

    def OnData(self, data):
        if self.IsWarmingUp:
            return
        
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
        if not self.Portfolio.Invested:
            self.Log("SmaHigh {0} READY. Samples: {1}".format("IS" if self.SmaHigh.IsReady else "IS NOT", self.SmaHigh.Samples))
            self.SetHoldings("EURUSD", 1)