Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Mariano Volpedo
    3. Best
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Best 2
    • Controversial 0
    • Groups 0

    Best posts made by Mariano Volpedo

    • MMI: Market Meanness Index

      Hi,

      To develop momentum strategies, its relevant to understand is the trend is strong or a mean reversion is coming. Tipically, Hurst Exponent claims to work, but unfortunally I dont see value on this indicator with my data (latinamerican mutual funds).

      Finally I found the MMI as an alternative with better results to implement in my strategies. You can get the explanation and several backtestings on https://financial-hacker.com/the-market-meanness-index/ (ps: you can read there with 55 is important)

      This is my implementation on backtrader, pls your feedback is welcome

      class MMI(bt.Indicator):
          lines = ('mmi',)
          plotinfo = dict(plothlines=[55])
          params = dict(period=100,)
      
          def __init__(self):
              self.m = Average(self.data.close, period = self.p.period) #replace with median
              
          def next(self):
                  nl = 0
                  nh = 0
      
                  for j in range(self.p.period-1):
                      if j < 1:
                          continue
                      i=j * -1
                      if (self.data.close[i] > self.m[0]) and (self.data.close[i] > self.data.close[i-1]) :
                          nl += 1
                      if (self.data.close[i] < self.m[0]) and (self.data.close[i] < self.data.close[i-1]) :
                          nh += 1
                  self.l.mmi[0] = 100.0 * (nl+nh)/(self.p.period - 1)
      posted in Indicators/Strategies/Analyzers
      Mariano Volpedo
      Mariano Volpedo
    • RE: How to output plots in a dark theme?

      This is my whole dark theme, I´ve tried to emulate TradingView schema.

      plt.style.use('fivethirtyeight')
      
      plt.rcParams["figure.figsize"] = (10, 6)
      plt.rcParams['lines.linewidth'] = 1
      
      SIZE = 7
      plt.rcParams['axes.labelsize'] = SIZE
      plt.rcParams['ytick.labelsize'] = SIZE
      plt.rcParams['xtick.labelsize'] = SIZE
      plt.rcParams["font.size"] = SIZE
      
      COLOR = '1'
      plt.rcParams['text.color'] = COLOR
      plt.rcParams['axes.labelcolor'] = COLOR
      plt.rcParams['xtick.color'] = COLOR
      plt.rcParams['ytick.color'] = COLOR
      
      
      plt.rcParams['grid.linewidth']=0.1
      plt.rcParams['grid.color']="0.2"
      plt.rcParams['lines.color']="0.5"
      plt.rcParams['axes.edgecolor']="0.2"
      plt.rcParams['axes.linewidth']=0.5
      
      plt.rcParams['figure.facecolor']="#101622"
      plt.rcParams['axes.facecolor']="#101622"
      plt.rcParams["savefig.dpi"]=120
      dpi = plt.rcParams["savefig.dpi"]
      width = 700
      height = 1200
      plt.rcParams['figure.figsize'] = height/dpi, width/dpi
      plt.rcParams["savefig.facecolor"] ="#101622"
      plt.rcParams["savefig.edgecolor"]="#101622"
      
      plt.rcParams['legend.fontsize'] = SIZE
      plt.rcParams['legend.title_fontsize'] = SIZE + 1
      plt.rcParams['legend.labelspacing'] =0.25
      plt.rcParams['image.cmap']='tab10'
      
      posted in General Discussion
      Mariano Volpedo
      Mariano Volpedo
    • 1 / 1