Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Kristofer Monisit
    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 5
    • Posts 8
    • Best 0
    • Groups 0

    Kristofer Monisit

    @Kristofer Monisit

    0
    Reputation
    73
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Kristofer Monisit Unfollow Follow

    Latest posts made by Kristofer Monisit

    • Resample data but do not plot it

      Currently I have daily data. I know how to resample it to weekly, monthly, yearly, etc. However, I only want to use it in indicator calculation. I do not want to plot the resampled data. How do I do it?

      posted in Indicators/Strategies/Analyzers
      Kristofer Monisit
      Kristofer Monisit
    • How do I access the Trade object from within the next() method of Strategy?

      I would like to keep track of the time I am currently in the trade. I know that the trade object has a barlen attribute. I would like to check for it in the next() method of the Strategy. How do I do it?

      https://cookbook.backtrader.com/documentation/trade/

      posted in General Discussion
      Kristofer Monisit
      Kristofer Monisit
    • RE: An indicator that knows if I have a position or not

      @momentum Thanks! I would add that Cerebro will have to be instantiated with Cerebro(runonce=False). Otherwise, if I use the default, i.e. runonce=True, all indicators would be precalculated all the way to the end, and they would not be able to observe if a trade is open or not.

      Reference for the runonce argument:
      https://www.backtrader.com/docu/cerebro.html?highlight=vectorize#backtrader.Cerebro

      posted in Indicators/Strategies/Analyzers
      Kristofer Monisit
      Kristofer Monisit
    • An indicator that knows if I have a position or not

      I am building an indicator that does one thing if I'm not in the trade, and does another if I'm in.

      Is it possible for a subclass of Indicators to access the position attribute of the Strategy?

      Of course, this indicator cannot be pre-computed, but is emits data as the backtest progresses.

      The following code surely raises AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute 'position'

      class CustomIndicator(bt.Indicator):
          lines = ('custom_indicator',)
          params = (('period', 14), )
          
          def next(self):
              if self.position:
                  self.lines.custom_indicator[0] = True and is_something_else_true()
                  self.do_something()
              else:
                  self.lines.custom_indicator[0] = False
                  self.do_nothing()
      
      posted in Indicators/Strategies/Analyzers
      Kristofer Monisit
      Kristofer Monisit
    • RE: Volume plot of PandasData uses the whole DataFrame as legend label

      I tried it again with a pristine installation of backtrader (pip install backtrader). With the defaults, it's OK, but with voloverlay=False, the entire DataFrame is printed.
      Imgur

      posted in General Discussion
      Kristofer Monisit
      Kristofer Monisit
    • Volume plot of PandasData uses the whole DataFrame as legend label

      I have the following DataFrame
      Imgur

      Then add it to cerebro and plot it:
      Imgur

      But the volume plot prints out the whole DataFrame as the legend label:
      Imgur

      How do I fix this?

      posted in General Discussion
      Kristofer Monisit
      Kristofer Monisit
    • RE: How to remove frame around the plot in Jupyter Notebook

      I have filed a pull request to do this: https://github.com/backtrader/backtrader/pull/384

      posted in General Discussion
      Kristofer Monisit
      Kristofer Monisit
    • How to remove frame around the plot in Jupyter Notebook

      How do I remove the frame around the plot in Jupyter Notebook? I do not need the interactive buttons.plot frame

      posted in General Discussion
      Kristofer Monisit
      Kristofer Monisit