@Kevin-Fu said in Building Sentiment Indicator class: TypeError: must be real number, not LineBuffer:

def next(self): self.date = self.data.datetime date = bt.num2date(self.date[0]).date() prev_sentiment = self.sentiment if date in date_sentiment: self.sentiment = date_sentiment[date] self.lines.sentiment[0] = self.sentiment

In any case that's probably where the error happens. There is no definition of self.sentiment and the indicator understands you are looking for the line named sentiment. The problems

Lack of variable initialization Conflicting naming