indicator using a value from the data other than close



  • I believe most of the built in indicators are using close value from the data for computation, for example SMA indicator is using close values of all the bars to derive sma... (is this correct)
    I have following 2 scenarios to build indicators

    1. if I would like to force this to use say high values of the bar to compute the average, what would be the change.
    2. if I would like to use volume from the bar to compute volume average over a period, what would be the change.
      appreciate any example if available.

  • administrators

    @skytrading54 said in indicator using a value from the data other than close:

    I believe most of the built in indicators are using close value from the data for computation, for example SMA indicator is using close values of all the bars to derive sma... (is this correct)

    This is wrong. The SMA uses the value from the 1st line of the data feed passed to it. For regular data feeds containing prices this happens to be the close price because this is the de-facto industry standard.

    See this post from yesterday where you can see that you can pass anything which is a line to any indicator:

    Just pass self.data.high or self.data.volume to the indicator of your choice.

    The exception are indicators which rely on specific price points like the Stochastic which uses 3 of the for usual price components (high, low, close ... leaving open unused)


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.