Supported Indicators

Kaufman Adaptive Moving Average

Introduction

This indicator computes the Kaufman Adaptive Moving Average (KAMA). The Kaufman Adaptive Moving Average is calculated as explained here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:kaufman_s_adaptive_moving_average

Create Manual Indicators

You can manually create a KaufmanAdaptiveMovingAverage indicator, so it doesn’t automatically update. Manual indicators let you update their values with any data you choose. The following reference table describes the KaufmanAdaptiveMovingAverage constructor.

KaufmanAdaptiveMovingAverage()1/2

            KaufmanAdaptiveMovingAverage QuantConnect.Indicators.KaufmanAdaptiveMovingAverage (
     string  name,
     int     period,
     *int    slowEmaPeriod
   )
        

Initializes a new instance of the KaufmanAdaptiveMovingAverage class using the specified name and period.

KaufmanAdaptiveMovingAverage()2/2

            KaufmanAdaptiveMovingAverage QuantConnect.Indicators.KaufmanAdaptiveMovingAverage (
     int   period,
     *int  slowEmaPeriod
   )
        

Initializes a new instance of the KaufmanAdaptiveMovingAverage class using the specified period.

Update Manual Indicators

You can update the indicator automatically or manually.

Automatic Update

To register a manual indicator for automatic updates with the security data, call the RegisterIndicator method.


private KaufmanAdaptiveMovingAverage _kama;

// In Initialize()
_kama = new KaufmanAdaptiveMovingAverage(name, period);
_kama.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _kama, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_kama.IsReady)
{
    var indicatorValue = _kama.Current.Value;
}
    
# In Initialize()
self.kama = KaufmanAdaptiveMovingAverage(name, period)
self.kama.Updated += self.IndicatorUpdateMethod

self.RegisterIndicator(symbol, self.kama, Resolution.Daily)

# In IndicatorUpdateMethod()
if self.kama.IsReady:
    indicator_value = self.kama.Current.Value

To customize the data that automatically updates the indicator, see Custom Indicator Periods and Custom Indicator Values.

Manual Update

Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update method with time/decimal pair. The indicator will only be ready after you prime it with enough data.

    
private KaufmanAdaptiveMovingAverage _kama;
private Symbol symbol;

// In Initialize()
_kama = new KaufmanAdaptiveMovingAverage(period);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.ContainsKey(_symbol))
{
    _kama.Update(data[symbol].EndTime, data[symbol].High);
}
if (_kama.IsReady)
{
    var indicatorValue = _kama.Current.Value;
}
    
# In Initialize()
self.kama = KaufmanAdaptiveMovingAverage(period)
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.ContainsKey(self.symbol):
    self.kama.Update(data[self.symbol].EndTime, data[self.symbol].High)
if self.kama.IsReady:
    indicator_value = self.kama.Current.Value

Create Automatic Indicators

The KAMA method creates an KaufmanAdaptiveMovingAverage indicator, sets up a consolidator to update the indicator, and then returns the indicator so you can use it in your algorithm.

The following reference table describes the KAMA method:

KAMA()1/2

            KaufmanAdaptiveMovingAverage QuantConnect.Algorithm.QCAlgorithm.KAMA (
    Symbol                           symbol,
    Int32                            period,
    *Nullable<Resolution>      resolution,
    *Func<IBaseData, Decimal>  selector
   )
        

Creates a new KaufmanAdaptiveMovingAverage indicator.

KAMA()2/2

            KaufmanAdaptiveMovingAverage QuantConnect.Algorithm.QCAlgorithm.KAMA (
    Symbol                           symbol,
    Int32                            period,
    Int32                            fastEmaPeriod,
    Int32                            slowEmaPeriod,
    *Nullable<Resolution>      resolution,
    *Func<IBaseData, Decimal>  selector
   )
        

Creates a new KaufmanAdaptiveMovingAverage indicator.


If you don't provide a resolution, it defaults to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.

For more information about the selector argument, see Alternative Price Fields.

Get Indicator Values

To get the value of the indicator, use its Current.Value attribute.

private KaufmanAdaptiveMovingAverage _kama;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_kama = KAMA(symbol, period, fastEmaPeriod, slowEmaPeriod);

// In OnData()
if (_kama.IsReady)
{
    var current = _kama.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.kama = self.KAMA(symbol, period, fastEmaPeriod, slowEmaPeriod)

# In OnData()
if self.kama.IsReady:
    current = self.kama.Current.Value

Visualization

To plot indicator values, in the OnData event handler, call the Plot method.

private KaufmanAdaptiveMovingAverage _kama;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_kama = KAMA(symbol, period, fastEmaPeriod, slowEmaPeriod);

// In OnData()
if (_kama.IsReady)
{
    Plot("My Indicators", "kaufmanadaptivemovingaverage", _kama.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.kama = self.KAMA(symbol, period, fastEmaPeriod, slowEmaPeriod)

# In OnData()
if self.kama.IsReady:
    self.Plot("My Indicators", "kaufmanadaptivemovingaverage", self.kama.Current)

The following image shows the plot values in a matplotlib plot. To load algorithm plot data into the Research Environment, see Charts.

For more information about plotting indicators, see Plotting Indicators.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: