Indicator Reference

Time Profile

Introduction

This indicator represents an Indicator of the Market Profile with Time Price Opportunity (TPO) mode and its attributes

Create Manual Indicators

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

TimeProfile()1/2

            TimeProfile QuantConnect.Indicators.TimeProfile (
     *int  period
   )
        

Creates a new TimeProfile indicator with the specified period.

TimeProfile()2/2

            TimeProfile QuantConnect.Indicators.TimeProfile (
     string    name,
     int       period,
     *decimal  priceRangeRoundOff
   )
        

Creates a new TimeProfile indicator with the specified name, period and priceRangeRoundOff.

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 TimeProfile _tp;

// In Initialize()
_tp = new TimeProfile(name, period);
_tp.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _tp, Resolution.Daily);

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

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

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

// In Initialize()
_tp = new TimeProfile(period);
symbol = AddEquity("SPY").Symbol;

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

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

Create Automatic Indicators

The TP method creates an TimeProfile 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 TP method:

TP()1/1

            TimeProfile QuantConnect.Algorithm.QCAlgorithm.TP (
    Symbol                            symbol,
    *Int32                            period,
    *Decimal                          valueAreaVolumePercentage,
    *Decimal                          priceRangeRoundOff,
    *Resolution                       resolution,
    *Func<IBaseData, TradeBar>  selector
   )
        

Creates an Market Profile indicator for the symbol with Time Price Opportunity (TPO) mode. 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 TimeProfile _tp;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_tp = TP(symbol);

// In OnData()
if (_tp.IsReady)
{
    var volumePerPrice = _tp.VolumePerPrice.Current.Value;
    var profileHigh = _tp.ProfileHigh.Current.Value;
    var profileLow = _tp.ProfileLow.Current.Value;
    var pOCPrice = _tp.POCPrice.Current.Value;
    var pOCVolume = _tp.POCVolume.Current.Value;
    var valueAreaVolume = _tp.ValueAreaVolume.Current.Value;
    var valueAreaHigh = _tp.ValueAreaHigh.Current.Value;
    var valueAreaLow = _tp.ValueAreaLow.Current.Value;
    var current = _tp.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.tp = self.TP(symbol)

# In OnData()
if self.tp.IsReady:
    volume_per_price = self.tp.VolumePerPrice.Current.Value
    profile_high = self.tp.ProfileHigh.Current.Value
    profile_low = self.tp.ProfileLow.Current.Value
    p_o_c_price = self.tp.POCPrice.Current.Value
    p_o_c_volume = self.tp.POCVolume.Current.Value
    value_area_volume = self.tp.ValueAreaVolume.Current.Value
    value_area_high = self.tp.ValueAreaHigh.Current.Value
    value_area_low = self.tp.ValueAreaLow.Current.Value
    current = self.tp.Current.Value

Visualization

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

private TimeProfile _tp;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_tp = TP(symbol);

// In OnData()
if (_tp.IsReady)
{
    Plot("My Indicators", "volumeperprice", _tp.VolumePerPrice);
    Plot("My Indicators", "profilehigh", _tp.ProfileHigh);
    Plot("My Indicators", "profilelow", _tp.ProfileLow);
    Plot("My Indicators", "pocprice", _tp.POCPrice);
    Plot("My Indicators", "pocvolume", _tp.POCVolume);
    Plot("My Indicators", "valueareavolume", _tp.ValueAreaVolume);
    Plot("My Indicators", "valueareahigh", _tp.ValueAreaHigh);
    Plot("My Indicators", "valuearealow", _tp.ValueAreaLow);
    Plot("My Indicators", "timeprofile", _tp.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.tp = self.TP(symbol)

# In OnData()
if self.tp.IsReady:
    self.Plot("My Indicators", "volumeperprice", self.tp.VolumePerPrice)
    self.Plot("My Indicators", "profilehigh", self.tp.ProfileHigh)
    self.Plot("My Indicators", "profilelow", self.tp.ProfileLow)
    self.Plot("My Indicators", "pocprice", self.tp.POCPrice)
    self.Plot("My Indicators", "pocvolume", self.tp.POCVolume)
    self.Plot("My Indicators", "valueareavolume", self.tp.ValueAreaVolume)
    self.Plot("My Indicators", "valueareahigh", self.tp.ValueAreaHigh)
    self.Plot("My Indicators", "valuearealow", self.tp.ValueAreaLow)
    self.Plot("My Indicators", "timeprofile", self.tp.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: