code: def next(self):
      if not self.position:
          # On upwards trend, if price closes above
          # "entry" MA, go long
  
          # Here, even though the operands are arrays, this
          # works by implicitly comparing the two last values
          if self.sma1 > self.sma2:
              if crossover(self.data.Close, self.sma_enter):
                  self.buy()
  
          # On downwards trend, if price closes below
          # "entry" MA, go short
  
          else:
              if crossover(self.sma_enter, self.data.Close):
                  self.sell()
  
      # But if we already hold a position and the price
      # closes back below (above) "exit" MA, close the position
  
      else:
          if (
              self.position.is_long
              and crossover(self.sma_exit, self.data.Close)
              or self.position.is_short
              and crossover(self.data.Close, self.sma_exit)
          ):
              self.position.close()
  
file_path: backtesting.py/doc/examples/Parameter Heatmap & Optimization.py
imports: from backtesting.test import SMA
  from backtesting import Strategy
  from backtesting.lib import crossover
  from backtesting import Backtest
  from backtesting.test import GOOG
  import seaborn
  from backtesting.lib import plot_heatmaps
  from skopt.plots import plot_objective
  from skopt.plots import plot_evaluations
label_desc: Use image node_id 2 for calling the Sma4Cross obj's underlying member method code with example usage: obj.next() without return types