Adding custom indicator

I have developed my first custom backtrader indicator class (in a separate file) which calculates resistance values. The first thing I do in the next() method of this indicator class is to get the previous 8 values of self.data and store them in an array named 'ltp', like so:

When I come to call the indicator in the init of my strategy, I pass in self.data[0]. But the self.data[0] doesn't seem to be available in the the indicator class. When I print out 'ltp' from the indicator class the array is empty.

Here is my strategy code for the init and main that isolates the problem:

When I come to call the indicator in the init of my strategy, I pass in self.data[0]. But the self.data[0] doesn't seem to be available in the the indicator class. When I print out 'ltp' from the indicator class the array is empty.

There is nothing telling the framework how many bars make up the lookback period. Neither you nor additional elements in your indicator (like a Moving Average) what the period will be. It cannot as such provide you with n bars of information in advance.

Subclass your indicator from: PeriodN which already provides a period parameter and will do it for you.