Using timer to execute the trade only once a day
I am trying to execute a trade only for first time in a day and ignore the signals thereafter. I read the documentation on timers and could not yet figure out how to use the flags to get it done. As of now I am doing something like below which does not seem to work. Could you please help ?
def __init__(self): # Keep a reference to the "close" line in the data dataseries self.dataopen = self.datas.open self.dataclose = self.datas.close self.datahigh = self.datas.high self.datalow = self.datas.low self.datahigh_prev = self.datas.high self.datalow_prev = self.datas.low # To keep track of pending orders and buy price/commission self.order = None self.buyprice = None self.buycomm = None self.ema = btind.MovAv.EMA(self.data, period=100) self.add_timer(when=bt.Timer.SESSION_START,flag=1) def notify_timer(self, timer, when,flag): if flag==1: self.next() flag==0