For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Which line in the data is SimpleMovingAverage based on?

  • In , a moving average is constructed like this:

    sma = btind.SimpleMovingAverage(self.datas[0], period=self.params.period)

    Wouldn't self.datas[0] contain several lines, i.e. self.datas[0].lines.close, self.datas[0], self.datas[0].lines.min, etc. according to whatever columns are in our data table?

    Which of these lines is the SMA based on? Follow up: does it ASSUME that we want compute SMA on "close" and are therefore required to include a "close" line in every data feed that is sent to the SMA function?

  • administrators

    No. If no specific line is passed, the 1st defined line is used. In the case of regular data feeds, close is defined as the 1st line to match the de-facto standard which is to do things directly on the close price.

Log in to reply