Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Some trades not executing while others are

    General Code/Help
    1
    1
    49
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dennis Musingila
      Dennis Musingila last edited by

      I have tried increasing cash and leverage but still I can't get all the trades to get executed. Here is a sample of my entry logic. It's is a simple rsi overbought and oversold strategy , number of trades are supposed to be at least 30 but i get only 8 executed trades,```

      def init(self):
      self.dataclose = self.data.close
      self.trade_tracker = []
      # Rsi
      self.rsi = btind.RSI(self.datas[0], period = 10)
      self.rsi_of_rsi = btind.RSI(self.rsi, period = 3)
      self.bar_executed = 0

      # william %r
      self.willr = btind.WilliamsR(self.datas[0],period = 30 )
      self.ma_willr = btind.SimpleMovingAverage(self.willr, period = 8)
      self.ma_willr.plotinfo.plotmaster = self.willr
      self.willr_sigs = btind.CrossOver(self.ma_willr, self.willr)
      
      self.ema_of_rsi = btind.SimpleMovingAverage(self.rsi, period = 10)
      self.ema = btind.SimpleMovingAverage(self.datas[0], period = 20)
      self.rsi_of_rsi.plotinfo.plotmaster = self.rsi
      self.buy_sigs = btind.CrossOver(self.rsi, 20)
      self.sell_sigs = btind.CrossDown(self.rsi, 70)
      

      def next(self):
      self.dt = self.data.datetime.datetime()
      if not self.position:
      if self.buy_sigs[0] :
      self.cash_before = self.broker.getcash()
      value = self.broker.get_value()
      entry = self.buy(size = self.params.size)
      entry.addinfo(name = 'buy')
      self.log('Buy Create %.4f,' % self.dataclose[0])

        elif self.sell_sigs[0]:
          value = self.broker.get_value()
          entry = self.sell(size = self.params.size)
          entry.addinfo(name = 'sell')
          self.log('sell Create %.4f' % self.dataclose[0])
        else:
          pass
      
      else:
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors