For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

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[0] dataseries
            self.dataopen = self.datas[0].open
            self.dataclose = self.datas[0].close
            self.datahigh = self.datas[0].high
            self.datalow = self.datas[0].low
            self.datahigh_prev = self.datas[1].high
            self.datalow_prev = self.datas[1].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(, period=100)
        def notify_timer(self, timer, when,flag):
            if flag==1:

Log in to reply