# Indicator Reference

## Beta

### Introduction

In technical analysis Beta indicator is used to measure volatility or risk of a target (ETF) relative to the overall risk (volatility) of the reference (market indexes). The Beta indicators compares target's price movement to the movements of the indexes over the same period of time. It is common practice to use the SPX index as a benchmark of the overall reference market when it comes to Beta calculations.

### Create Manual Indicators

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

### Beta()1/1

            Beta QuantConnect.Indicators.Beta (
string  name,
int     period,
Symbol  referenceSymbol
)


reference values.

### 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 Beta _b;

// In Initialize()
_b = new Beta(name, period, targetSymbol, referenceSymbol);
_b.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _b, Resolution.Daily);

// In IndicatorUpdateMethod()
{
var indicatorValue = _b.Current.Value;
}

# In Initialize()
self.b = Beta(name, period, targetSymbol, referenceSymbol)
self.b.Updated += self.IndicatorUpdateMethod

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

# In IndicatorUpdateMethod()
indicator_value = self.b.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 Beta _b;

// In Initialize()
_b = new Beta(period, targetSymbol, referenceSymbol);

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
_b.Update(data.Bars[symbol]);
}
{
var indicatorValue = _b.Current.Value;
}

# In Initialize()
self.b = Beta(period, targetSymbol, referenceSymbol)

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

### Create Automatic Indicators

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

### B()1/1

            Beta QuantConnect.Algorithm.QCAlgorithm.B (
Symbol                       target,
Symbol                       reference,
Int32                        period,
*Nullable<Resolution>  resolution
)


Creates a Beta indicator for the given target symbol in relation with the reference used. The indicator will be automatically updated on the given resolution.

If you don't provide a resolution, it defauls 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.

### Get Indicator Values

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

private Beta _b;

// In Initialize()

_b = B(target, reference, period);

// In OnData()
{
var current = _b.Current.Value;
}
# In Initialize()

self.b = self.B(target, reference, period)

# In OnData()
current = self.b.Current.Value


### Visualization

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

private Beta _b;

// In Initialize()

_b = B(target, reference, period);

// In OnData()
{
Plot("My Indicators", "beta", _b.Current);
}
# In Initialize()

self.b = self.B(target, reference, period)

# In OnData()