Hello, I have written some code that isn't placing trades and I could use some assistance. What I am trying to test is a system where the 10 day ema of the security is the directional bias, the 10 hour ema is a confirmation of direction, the 14 period hourly rsi is a pullback parameter with signals at 30 for upward bias and 80 for downward bias, and finally using the 1 minute rsi for timing of entries and exits to be on the side of momentum. It should go long when the above params are met for longs and the 1 minute rsi is above 50 and close when it drops below 30, and go short when under 50 and close our above 80 when the above params indicates a bias short. 

Ps. Code is written in python.

 

class HyperActiveMagentaAlligator(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 12, 26)  # Set Start Date
        self.SetEndDate(2022,2,26)
        self.SetCash(100000)  # Set Strategy Cash
        # self.AddEquity("SPY", Resolution.Minute)
        self.spy = self.AddSecurity("SPY",Resolution.Minute)
        self.bias = self.EMA("SPY", 10, Resolution.Daily)
        self.confirmation = self.EMA("SPY", 10, Resolution.Hour)
        self.pullback = self.RSI("SPY", 14, Resolution.Hour)
        self.timing = self.RSI("SPY", 14, Resolution.Minute)
        
        
        
        
        


    def OnData(self, data):
        
        if not self.Portfolio.Invested:
            if self.Securities["SPY"].Close > self.bias.Current.Value:
                if self.Securities["SPY"].Close > self.confirmation.Current.Value:
                    if self.pullback < 30:
                        if self.timing > 50:
                            self.SetHoldings("SPY", 1)
            if self.Securities["SPY"].Close < self.bias.Current.Value:
                if self.Securities["SPY"].Close < self.confirmation.Current.Value:
                    if self.pullback > 80:
                        if self.timing < 50:
                            self.SetHoldings("SPY", -1)
        if self.Portfolio.Invested:
            if self.Holdings > 0:
                if self.timing < 30:
                    self.SetHoldings("SPY", 0)
            if self.Holdings < 0 :
                if self.timing > 80:
                    self.SetHoldings("SPY", 0)