Supported Indicators

Arms Index

Introduction

The Arms Index, also called the Short-Term Trading Index (TRIN) is a technical analysis indicator that compares the number of advancing and declining stocks (AD Ratio) to advancing and declining volume (AD volume).

Create Manual Indicators

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

ArmsIndex()1/1

            ArmsIndex QuantConnect.Indicators.ArmsIndex (
     string  name
   )
        

Initializes a new instance of the ArmsIndex class.

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 ArmsIndex _trin;

// In Initialize()
_trin = new ArmsIndex();
_trin.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _trin, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_trin.IsReady)
{
    var indicatorValue = _trin.Current.Value;
}
    
# In Initialize()
self.trin = ArmsIndex()
self.trin.Updated += self.IndicatorUpdateMethod

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

# In IndicatorUpdateMethod()
if self.trin.IsReady:
    indicator_value = self.trin.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 a TradeBar. The indicator will only be ready after you prime it with enough data.

    
private ArmsIndex _trin;
private List<Symbol> symbols;

// In Initialize()
_trin = new ArmsIndex();
symbols = new List<Symbol> {AddEquity("SPY").Symbol, AddEquity("QQQ").Symbol};

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
    _trin.Update(data.Bars[symbol]);
}
if (_trin.IsReady)
{
    var indicatorValue = _trin.Current.Value;
}
    
# In Initialize()
self.trin = ArmsIndex()
self.symbols = [self.AddEquity("SPY").Symbol, self.AddEquity("QQQ").Symbol]

# In OnData()
if data.Bars.ContainsKey(self.symbol):
    self.trin.Update(data.Bars[self.symbol])
if self.trin.IsReady:
    indicator_value = self.trin.Current.Value

Create Automatic Indicators

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

TRIN()1/2

            ArmsIndex QuantConnect.Algorithm.QCAlgorithm.TRIN (
    IEnumerable<Symbol>    symbols,
    *Nullable<Resolution>  resolution
   )
        

TRIN()2/2

            ArmsIndex QuantConnect.Algorithm.QCAlgorithm.TRIN (
    Symbol>                   symbols,
    *Nullable<Resolution>  resolution
   )
        

Creates a new Arms Index 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 ArmsIndex _trin;

// In Initialize()
var symbols = new[] {AddEquity("SPY").Symbol, AddEquity("QQQ").Symbol};
_trin = TRIN(symbols);

// In OnData()
if (_trin.IsReady)
{
    var aDRatio = _trin.ADRatio.Current.Value;
    var aDVRatio = _trin.ADVRatio.Current.Value;
    var current = _trin.Current.Value;
}
# In Initialize()
symbols = [self.AddEquity("SPY").Symbol, self.AddEquity("QQQ").Symbol]
self.trin = self.TRIN(symbols)

# In OnData()
if self.trin.IsReady:
    a_d_ratio = self.trin.ADRatio.Current.Value
    a_d_v_ratio = self.trin.ADVRatio.Current.Value
    current = self.trin.Current.Value

Visualization

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

private ArmsIndex _trin;

// In Initialize()
var symbols = new[] {AddEquity("SPY").Symbol, AddEquity("QQQ").Symbol};
_trin = TRIN(symbols);

// In OnData()
if (_trin.IsReady)
{
    Plot("My Indicators", "adratio", _trin.ADRatio);
    Plot("My Indicators", "advratio", _trin.ADVRatio);
    Plot("My Indicators", "armsindex", _trin.Current);
}
# In Initialize()
symbols = [self.AddEquity("SPY").Symbol, self.AddEquity("QQQ").Symbol]
self.trin = self.TRIN(symbols)

# In OnData()
if self.trin.IsReady:
    self.Plot("My Indicators", "adratio", self.trin.ADRatio)
    self.Plot("My Indicators", "advratio", self.trin.ADVRatio)
    self.Plot("My Indicators", "armsindex", self.trin.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: