access indicator member variables
-
In the indicator I populate a list defined on
self
:class SomeIndicator(bt.Indicator): def __init__(self): self.someList = [] def next(self): self.someList.append('something')
In the strategy I want to access the someList like that:
class DummyStrategy(bt.Strategy): def __init__(self): self.someIndicator = SomeIndicator() def next(self): print(self.someIndicator.someList)
The problem is that I always get the latest state of
self.someIndicator.someList
. As a result I get a print of the lastsomeList
over and over depending on the length of data.The question is how can I properly access a member variable of an indicator to be used in the
next
of a strategy? -
@eduedix said in access indicator member variables:
The question is how can I properly access a member variable of an indicator to be used in the next of a strategy?
There seems to be some misunderstanding here. You are already accessing the member variable and you get the last value because you keep on appending things to it.
Where is the problem?
-
The problem is I don't see the intermediate steps. For example, let's say
len(data)
is3
. In the print outs I see the latest step3
times:['something', 'something', 'something'] ['something', 'something', 'something'] ['something', 'something', 'something']
instead of
['something'] ['something', 'something'] ['something', 'something', 'something']
-
@eduedix said in access indicator member variables:
The problem is I don't see the intermediate steps. For example, let's say
len(data)
is3
. In the print outs I see the latest step3
times:['something', 'something', 'something'] ['something', 'something', 'something'] ['something', 'something', 'something']
instead of
['something'] ['something', 'something'] ['something', 'something', 'something']
If the
len(data) == 3
you are bound to see 3somethings
You'd be better off posting a complete working sample that makes sense.