code: def onBars(self, bars):
      lower = self.__bbands.getLowerBand()[-1]
      upper = self.__bbands.getUpperBand()[-1]
      if lower is None:
          return
  
      shares = self.getBroker().getShares(self.__instrument)
      bar = bars[self.__instrument]
      if shares == 0 and bar.getClose() < lower:
          sharesToBuy = int(
              self.getBroker().getCash(False) / bar.getClose()
          )
          self.info(
              "Placing buy market order for %s shares" % sharesToBuy
          )
          self.marketOrder(self.__instrument, sharesToBuy)
      elif shares > 0 and bar.getClose() > upper:
          self.info("Placing sell market order for %s shares" % shares)
          self.marketOrder(self.__instrument, -1 * shares)
  
file_path: pyalgotrade/samples/bbands.py
imports: from __future__ import print_function
  from pyalgotrade import strategy
  from pyalgotrade import plotter
  from pyalgotrade.tools import quandl
  from pyalgotrade.technical import bollinger
  from pyalgotrade.stratanalyzer import sharpe
  from pyalgotrade import broker
label_desc: Use image node_id 4 for calling the BBands obj's underlying member method code with example usage: obj.onBars(bars) without return types