class_docstr: This strategy is loosely based on some of the examples from the Van
  K. Tharp book: *Trade Your Way To Financial Freedom*. The logic:
  
    - Enter the market if:
      - The MACD.macd line crosses the MACD.signal line to the upside
      - The Simple Moving Average has a negative direction in the last x
        periods (actual value below value x periods ago)
  
   - Set a stop price x times the ATR value away from the close
  
   - If in the market:
  
     - Check if the current close has gone below the stop price. If yes,
       exit.
     - If not, update the stop price if the new stop price would be higher
       than the current
class_docstr_tok: ["This","strategy","is","loosely","based","on","some","of","the","examples","from","the","Van","K.","Tharp","book",":","*","Trade","Your","Way","To","Financial","Freedom","*",".","The","logic",":","-","Enter","the","market","if",":","-","The","MACD.macd","line","crosses","the","MACD.signal","line","to","the","upside","-","The","Simple","Moving","Average","has","a","negative","direction","in","the","last","x","periods","(","actual","value","below","value","x","periods","ago",")","-","Set","a","stop","price","x","times","the","ATR","value","away","from","the","close","-","If","in","the","market",":","-","Check","if","the","current","close","has","gone","below","the","stop","price",".","If","yes",",","exit",".","-","If","not",",","update","the","stop","price","if","the","new","stop","price","would","be","higher","than","the","current"]
code: def __init__(self):
      self.macd = bt.indicators.MACD(
          self.data,
          period_me1=self.p.macd1,
          period_me2=self.p.macd2,
          period_signal=self.p.macdsig,
      )
  
      # Cross of macd.macd and macd.signal
      self.mcross = bt.indicators.CrossOver(
          self.macd.macd, self.macd.signal
      )
  
      # To set the stop price
      self.atr = bt.indicators.ATR(self.data, period=self.p.atrperiod)
  
      # Control market trend
      self.sma = bt.indicators.SMA(self.data, period=self.p.smaperiod)
      self.smadir = self.sma - self.sma(-self.p.dirperiod)
  
file_path: backtrader/samples/macd-settings/macd-settings.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import random
  import backtrader
label_desc: Use image node_id 2 to create a new TheStrategy object from inherited base classes: bt with example: obj = TheStrategy()