Indicator Reference

Relative Daily Volume

Introduction

The Relative Daily Volume indicator is an indicator that compares current cumulative volume to the cumulative volume for a given time of day, measured as a ratio. Current volume from open to current time of day / Average over the past x days from open to current time of day

Create Manual Indicators

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

RelativeDailyVolume()1/2

            RelativeDailyVolume QuantConnect.Indicators.RelativeDailyVolume (
     *int  period
   )
        

Initializes a new instance of the RelativeDailyVolume class using the specified period.

RelativeDailyVolume()2/2

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

Creates a new RelativeDailyVolume indicator with the specified period.

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 RelativeDailyVolume _rdv;

// In Initialize()
_rdv = new RelativeDailyVolume(name, period);
_rdv.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _rdv, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_rdv.IsReady)
{
    var indicatorValue = _rdv.Current.Value;
}
    
# In Initialize()
self.rdv = RelativeDailyVolume(name, period)
self.rdv.Updated += self.IndicatorUpdateMethod

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

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

// In Initialize()
_rdv = new RelativeDailyVolume(period);
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
    _rdv.Update(data.Bars[symbol]);
}
if (_rdv.IsReady)
{
    var indicatorValue = _rdv.Current.Value;
}
    
# In Initialize()
self.rdv = RelativeDailyVolume(period)
self.symbol = self.AddEquity("SPY").Symbol

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

Create Automatic Indicators

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

RDV()1/1

            RelativeDailyVolume QuantConnect.Algorithm.QCAlgorithm.RDV (
    Symbol                            symbol,
    *Int32                            period,
    *Resolution                       resolution,
    *Func<IBaseData, TradeBar>  selector
   )
        

Creates an RelativeDailyVolume 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 RelativeDailyVolume _rdv;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_rdv = RDV(symbol);

// In OnData()
if (_rdv.IsReady)
{
    var current = _rdv.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.rdv = self.RDV(symbol)

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

Visualization

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

private RelativeDailyVolume _rdv;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_rdv = RDV(symbol);

// In OnData()
if (_rdv.IsReady)
{
    Plot("My Indicators", "relativedailyvolume", _rdv.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.rdv = self.RDV(symbol)

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