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?
Latest posts made by 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
barlenattribute. I would like to check for it in the
next()method of the Strategy. How do I do it?
RE: An indicator that knows if I have a position or not
@momentum Thanks! I would add that
Cerebrowill 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
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
Indicatorsto access the
positionattribute of the
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 = True and is_something_else_true() self.do_something() else: self.lines.custom_indicator = False self.do_nothing()
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.
Volume plot of PandasData uses the whole DataFrame as legend label
I have the following DataFrame
Then add it to
cerebroand plot it:
But the volume plot prints out the whole DataFrame as the legend label:
How do I fix this?
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
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.