backtrader.indicators.smma module

SMMA Indicator Module - Smoothed Moving Average.

This module provides the SMMA (Smoothed Moving Average) indicator used by J. Welles Wilder in his 1978 book.

Classes:
SmoothedMovingAverage: SMMA indicator (aliases: SMMA, WilderMA,

MovingAverageSmoothed, MovingAverageWilder, ModifiedMovingAverage).

Example

class MyStrategy(bt.Strategy):
def __init__(self):

self.smma = bt.indicators.SMMA(self.data.close, period=14)

def next(self):
if self.data.close[0] > self.smma[0]:

self.buy()

class backtrader.indicators.smma.SmoothedMovingAverage[source]

Bases: MovingAverageBase

Smoothing Moving Average used by Wilder in his 1978 book New Concepts in Technical Trading

Defined in his book originally as:

  • new_value = (old_value * (period - 1) + new_data) / period

It Can be expressed as a SmoothingMovingAverage with the following factors:

  • self.smfactor -> 1.0 / period

  • self.smfactor1 -> 1.0 - self.smfactor

Formula:
  • movav = prev * (1.0 - smoothfactor) + newdata * smoothfactor

alias = ('SMMA', 'WilderMA', 'MovingAverageSmoothed', 'MovingAverageWilder', 'ModifiedMovingAverage')
__init__(*args, **kwargs)
nextstart()[source]

Seed SMMA calculation with SMA on first valid bar.

Initializes with simple moving average of the first period values.

next()[source]

Calculate SMMA for the current bar.

Formula: SMMA = prev_SMMMA * alpha1 + current_price * alpha where alpha = 1/period and alpha1 = 1 - alpha.

once(start, end)[source]

Calculate SMMA in runonce mode

frompackages = ()
packages = ()