code: def onBars(self, bars):
      # Wait for enough bars to be available to calculate a SMA.
      if self.__sma[-1] is None:
          return
  
      bar = bars[self.__instrument]
      # If a position was not opened, check if we should enter a long position.
      if self.__position is None:
          if bar.getPrice() > self.__sma[-1]:
              # Enter a buy market order for 10 shares. The order is good till canceled.
              self.__position = self.enterLong(
                  self.__instrument, 10, True
              )
      # Check if we have to exit the position.
      elif (
          bar.getPrice() < self.__sma[-1]
          and not self.__position.exitActive()
      ):
          self.__position.exitMarket()
  
file_path: pyalgotrade/samples/tutorial-4.py
imports: from __future__ import print_function
  from pyalgotrade import strategy
  from pyalgotrade.barfeed import quandlfeed
  from pyalgotrade.technical import ma
label_desc: Use image node_id 6 for calling the MyStrategy obj's underlying member method code with example usage: obj.onBars(bars) without return types