# Indicator Reference

## Average Directional Index

### Introduction

This indicator computes Average Directional Index which measures trend strength without regard to trend direction. Firstly, it calculates the Directional Movement and the True Range value, and then the values are accumulated and smoothed using a custom smoothing method proposed by Wilder. For an n period smoothing, 1/n of each period's value is added to the total period. From these accumulated values we are therefore able to derived the 'Positive Directional Index' (+DI) and 'Negative Directional Index' (-DI) which is used to calculate the Average Directional Index. Computation source: https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:average_directional_index_adx

### Create Manual Indicators

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

### AverageDirectionalIndex()1/2

            AverageDirectionalIndex QuantConnect.Indicators.AverageDirectionalIndex (
int  period
)


Initializes a new instance of the AverageDirectionalIndex class.

### AverageDirectionalIndex()2/2

            AverageDirectionalIndex QuantConnect.Indicators.AverageDirectionalIndex (
string  name,
int     period
)


Initializes a new instance of the AverageDirectionalIndex 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.



// In Initialize()

// In IndicatorUpdateMethod()
{
}

# In Initialize()

# In IndicatorUpdateMethod()
indicator_value = self.adx.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, QuoteBar, or an IndicatorDataPoint. The indicator will only be ready after you prime it with enough data.


private Symbol symbol;

// In Initialize()

// In OnData()
if (data.QuoteBars.ContainsKey(_symbol))
{
}
{
}

# In Initialize()

# In OnData()
if data.QuoteBars.ContainsKey(self.symbol):
indicator_value = self.adx.Current.Value

### Create Automatic Indicators

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

            AverageDirectionalIndex QuantConnect.Algorithm.QCAlgorithm.ADX (
Symbol                                symbol,
Int32                                 period,
*Nullable<Resolution>           resolution,
*Func<IBaseData, IBaseDataBar>  selector
)


Creates a new Average Directional Index indicator. 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 AverageDirectionalIndex _adx;

// In Initialize()

// In OnData()
{
}
# In Initialize()

# In OnData()


### Visualization

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

private AverageDirectionalIndex _adx;

// In Initialize()

// In OnData()
{
}
# In Initialize()

# In OnData()