Indicator Reference

Wilder Accumulative Swing Index

Introduction

This indicator calculates the Accumulative Swing Index (ASI) as defined by Welles Wilder in his book 'New Concepts in Technical Trading Systems'. ASIₜ = ASIₜ₋₁ + SIₜ Where: ASIₜ₋₁ The for the previous period. SIₜ The calculated for the current period.

Create Manual Indicators

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

WilderAccumulativeSwingIndex()1/2

            WilderAccumulativeSwingIndex QuantConnect.Indicators.WilderAccumulativeSwingIndex (
     decimal  limitMove
   )
        

Initializes a new instance of the WilderAccumulativeSwingIndex class using the specified name.

WilderAccumulativeSwingIndex()2/2

            WilderAccumulativeSwingIndex QuantConnect.Indicators.WilderAccumulativeSwingIndex (
     string   name,
     decimal  limitMove
   )
        

Initializes a new instance of the WilderAccumulativeSwingIndex class using 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 WilderAccumulativeSwingIndex _asi;

// In Initialize()
_asi = new WilderAccumulativeSwingIndex(name, limitMove);
_asi.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _asi, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_asi.IsReady)
{
    var indicatorValue = _asi.Current.Value;
}
    
# In Initialize()
self.asi = WilderAccumulativeSwingIndex(name, limitMove)
self.asi.Updated += self.IndicatorUpdateMethod

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

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

// In Initialize()
_asi = new WilderAccumulativeSwingIndex(limitMove);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
    _asi.Update(data.Bars[symbol]);
}
if (_asi.IsReady)
{
    var indicatorValue = _asi.Current.Value;
}
    
# In Initialize()
self.asi = WilderAccumulativeSwingIndex(limitMove)
self.symbol = self.AddEquity("SPY").Symbol

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

Create Automatic Indicators

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

ASI()1/1

            WilderAccumulativeSwingIndex QuantConnect.Algorithm.QCAlgorithm.ASI (
    Symbol                       symbol,
    Decimal                      limitMove,
    *Nullable<Resolution>  resolution
   )
        

Creates a Wilder Accumulative Swing Index (ASI) indicator for the symbol. 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.

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 WilderAccumulativeSwingIndex _asi;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_asi = ASI(symbol, limitMove);

// In OnData()
if (_asi.IsReady)
{
    var current = _asi.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.asi = self.ASI(symbol, limitMove)

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

Visualization

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

private WilderAccumulativeSwingIndex _asi;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_asi = ASI(symbol, limitMove);

// In OnData()
if (_asi.IsReady)
{
    Plot("My Indicators", "wilderaccumulativeswingindex", _asi.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.asi = self.ASI(symbol, limitMove)

# In OnData()
if self.asi.IsReady:
    self.Plot("My Indicators", "wilderaccumulativeswingindex", self.asi.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: