Supported Indicators

Filtered Identity

Introduction

This indicator represents an indicator that is a ready after ingesting a single sample and always returns the same value as it is given if it passes a filter condition

Create Manual Indicators

You can manually create a FilteredIdentity 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 FilteredIdentity constructor.

FilteredIdentity()1/1

            FilteredIdentity QuantConnect.Indicators.FilteredIdentity (
     string  name
   )
        

Initializes a new instance of the FilteredIdentity indicator with the specified name.

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 FilteredIdentity _filteredidentity;

// In Initialize()
_filteredidentity = new FilteredIdentity(name, filter);
_filteredidentity.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _filteredidentity, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_filteredidentity.IsReady)
{
    var indicatorValue = _filteredidentity.Current.Value;
}
    
# In Initialize()
self.filteredidentity = FilteredIdentity(name, filter)
self.filteredidentity.Updated += self.IndicatorUpdateMethod

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

# In IndicatorUpdateMethod()
if self.filteredidentity.IsReady:
    indicator_value = self.filteredidentity.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 FilteredIdentity _filteredidentity;
private Symbol symbol;

// In Initialize()
_filteredidentity = new FilteredIdentity(filter);
symbol = AddEquity("SPY").Symbol;

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

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

Create Automatic Indicators

The FilteredIdentity method creates an FilteredIdentity 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 FilteredIdentity method:

FilteredIdentity()1/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol     symbol,
    *PyObject  selector,
    *PyObject  filter,
    *String    fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

FilteredIdentity()2/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol      symbol,
    Resolution  resolution,
    *PyObject   selector,
    *PyObject   filter,
    *String     fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

FilteredIdentity()3/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol     symbol,
    TimeSpan   resolution,
    *PyObject  selector,
    *PyObject  filter,
    *String    fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

FilteredIdentity()4/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol                                symbol,
    *Func<IBaseData, IBaseDataBar>  selector,
    *Func<IBaseData, Boolean>       filter,
    *String                               fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

FilteredIdentity()5/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol                                symbol,
    Resolution                            resolution,
    *Func<IBaseData, IBaseDataBar>  selector,
    *Func<IBaseData, Boolean>       filter,
    *String                               fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution

FilteredIdentity()6/6

            FilteredIdentity QuantConnect.Algorithm.QCAlgorithm.FilteredIdentity (
    Symbol                                symbol,
    TimeSpan                              resolution,
    *Func<IBaseData, IBaseDataBar>  selector,
    *Func<IBaseData, Boolean>       filter,
    *String                               fieldName
   )
        

Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically updated on the symbol's subscription resolution


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 FilteredIdentity _filteredidentity;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_filteredidentity = FilteredIdentity(symbol, resolution);

// In OnData()
if (_filteredidentity.IsReady)
{
    var current = _filteredidentity.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.filteredidentity = self.FilteredIdentity(symbol, resolution)

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

Visualization

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

private FilteredIdentity _filteredidentity;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_filteredidentity = FilteredIdentity(symbol, resolution);

// In OnData()
if (_filteredidentity.IsReady)
{
    Plot("My Indicators", "filteredidentity", _filteredidentity.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.filteredidentity = self.FilteredIdentity(symbol, resolution)

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

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: