Lets say you had the example code below, one function responsible for a buy condition and one for a sell condition that were each ran at the scheduler at a timed cadence.  Well lets say the Buy signal triggered, followed by the sell signal.  Before allowing the Buy Signal to fire again, I want a 7 day pause.  How would one best go about this?
 

from AlgorithmImports import *
from QuantConnect.Data.Market import TradeBar

class RollingWindowAlgorithm(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2022,1,1) #Set Start Date
#self.SetEndDate(2021,10,1) 
self.Tickers = ('SPY','QQQ')
self.SetCash(100000)


for symbol in self.tickers:
	self.AddEquity(symbol, Resolution.Hour).Symbol
	sma20 = self.SMA(symbol, 20, Resolution.Daily, Field.Close)
	sma50 = self.SMA(symbol, 50, Resolution.Daily, Field.Close)
	symbolData = SymbolData(symbol, sma20, sma50)
	self.symbolDataBySymbol[symbol] = symbolData


self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 10), self.BuySignal)
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 10), self.SellSignal)


def OnData(self, data):
pass



def BuySignal(self):
	if self.trade == False:
		return
	for symbol, symbolData in self.symbolDataBySymbol.items():
		if not self.Portfolio[symbol].Invested and (self.Securities[symbol].Close > symbolData.sma20.Current.Value):
			self.SetHoldings(symbol, .1, False, "Buy Signal")

def SellSignal(self):
	if self.trade == False:
		return	
	for symbol, symbolData in self.symbolDataBySymbol.items():
		if self.Portfolio[symbol].Invested and (symbolData.sma20.Current.Value < symbolData.sma50.Current.Value):
			self.Liquidate()
			#SOME FORM OF LOGIC THAT DELAYS self.BuySignal from firing for 7 days, regardless of the Scheduler



class SymbolData:
	def __init__(self, symbol, sma20,sma50):
	self.Symbol = symbol
	self.sma20 = sma20
	self.sma50 = sma50

 

Is there a way to count x amount of days before allowing the BuySignal function to be run again?

Author