Supported Indicators
Time Profile
Introduction
This indicator represents an Indicator of the Market Profile with Time Price Opportunity (TPO) mode and its attributes
To view the implementation of this indicator, see the LEAN GitHub repository.
Using TP Indicator
To create an automatic indicators for TimeProfile
, call the TP
helper method from the QCAlgorithm
class. The TP
method creates a TimeProfile
object, hooks it up for automatic updates, and returns it so you can used it in your algorithm. In most cases, you should call the helper method in the Initialize
method.
public class TimeProfileAlgorithm : QCAlgorithm { private Symbol _symbol; private TimeProfile _tp; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _tp = TP("SPY", 3, 0.70, 0.05); } public override void OnData(Slice data) { if (_tp.IsReady) { // The current value of _tp is represented by itself (_tp) // or _tp.Current.Value Plot("TimeProfile", "tp", _tp); // Plot all properties of tp Plot("TimeProfile", "volumeperprice", _tp.VolumePerPrice); Plot("TimeProfile", "profilehigh", _tp.ProfileHigh); Plot("TimeProfile", "profilelow", _tp.ProfileLow); Plot("TimeProfile", "pocprice", _tp.POCPrice); Plot("TimeProfile", "pocvolume", _tp.POCVolume); Plot("TimeProfile", "valueareavolume", _tp.ValueAreaVolume); Plot("TimeProfile", "valueareahigh", _tp.ValueAreaHigh); Plot("TimeProfile", "valuearealow", _tp.ValueAreaLow); } } }
class TimeProfileAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.tp = self.TP("SPY", 3, 0.70, 0.05) def OnData(self, slice: Slice) -> None: if self.tp.IsReady: # The current value of self.tp is represented by self.tp.Current.Value self.Plot("TimeProfile", "tp", self.tp.Current.Value) # Plot all attributes of self.tp self.Plot("TimeProfile", "volumeperprice", self.tp.VolumePerPrice.Current.Value) self.Plot("TimeProfile", "profilehigh", self.tp.ProfileHigh.Current.Value) self.Plot("TimeProfile", "profilelow", self.tp.ProfileLow.Current.Value) self.Plot("TimeProfile", "pocprice", self.tp.POCPrice.Current.Value) self.Plot("TimeProfile", "pocvolume", self.tp.POCVolume.Current.Value) self.Plot("TimeProfile", "valueareavolume", self.tp.ValueAreaVolume.Current.Value) self.Plot("TimeProfile", "valueareahigh", self.tp.ValueAreaHigh.Current.Value) self.Plot("TimeProfile", "valuearealow", self.tp.ValueAreaLow.Current.Value)
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 defaults 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.
For more information about plotting indicators, see Plotting 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.
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.
public class TimeProfileAlgorithm : QCAlgorithm { private Symbol _symbol; private TimeProfile _tp; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _tp = new TimeProfile(3, 0.70, 0.05); } public override void OnData(Slice data) { if (data.Bars.TryGeValue(_symbol, out var bar)) { _tp.Update(bar); } if (_tp.IsReady) { // The current value of _tp is represented by itself (_tp) // or _tp.Current.Value Plot("TimeProfile", "tp", _tp); // Plot all properties of tp Plot("TimeProfile", "volumeperprice", _tp.VolumePerPrice); Plot("TimeProfile", "profilehigh", _tp.ProfileHigh); Plot("TimeProfile", "profilelow", _tp.ProfileLow); Plot("TimeProfile", "pocprice", _tp.POCPrice); Plot("TimeProfile", "pocvolume", _tp.POCVolume); Plot("TimeProfile", "valueareavolume", _tp.ValueAreaVolume); Plot("TimeProfile", "valueareahigh", _tp.ValueAreaHigh); Plot("TimeProfile", "valuearealow", _tp.ValueAreaLow); } } }
class TimeProfileAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.tp = TimeProfile(3, 0.70, 0.05) def OnData(self, slice: Slice) -> None: bar = slice.Bars.get(self.symbol) if bar: self.tp.Update(bar) if self.tp.IsReady: # The current value of self.tp is represented by self.tp.Current.Value self.Plot("TimeProfile", "tp", self.tp.Current.Value) # Plot all attributes of self.tp self.Plot("TimeProfile", "volumeperprice", self.tp.VolumePerPrice.Current.Value) self.Plot("TimeProfile", "profilehigh", self.tp.ProfileHigh.Current.Value) self.Plot("TimeProfile", "profilelow", self.tp.ProfileLow.Current.Value) self.Plot("TimeProfile", "pocprice", self.tp.POCPrice.Current.Value) self.Plot("TimeProfile", "pocvolume", self.tp.POCVolume.Current.Value) self.Plot("TimeProfile", "valueareavolume", self.tp.ValueAreaVolume.Current.Value) self.Plot("TimeProfile", "valueareahigh", self.tp.ValueAreaHigh.Current.Value) self.Plot("TimeProfile", "valuearealow", self.tp.ValueAreaLow.Current.Value)
To register a manual indicator for automatic updates with the security data, call the RegisterIndicator
method.
public class TimeProfileAlgorithm : QCAlgorithm { private Symbol _symbol; private TimeProfile _tp; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _tp = new TimeProfile(3, 0.70, 0.05); RegisterIndicator(_symbol, _tp, Resolution.Daily); } public override void OnData(Slice data) { if (_tp.IsReady) { // The current value of _tp is represented by itself (_tp) // or _tp.Current.Value Plot("TimeProfile", "tp", _tp); // Plot all properties of tp Plot("TimeProfile", "volumeperprice", _tp.VolumePerPrice); Plot("TimeProfile", "profilehigh", _tp.ProfileHigh); Plot("TimeProfile", "profilelow", _tp.ProfileLow); Plot("TimeProfile", "pocprice", _tp.POCPrice); Plot("TimeProfile", "pocvolume", _tp.POCVolume); Plot("TimeProfile", "valueareavolume", _tp.ValueAreaVolume); Plot("TimeProfile", "valueareahigh", _tp.ValueAreaHigh); Plot("TimeProfile", "valuearealow", _tp.ValueAreaLow); } } }
class TimeProfileAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.tp = TimeProfile(3, 0.70, 0.05) self.RegisterIndicator(self.symbol, self.tp, Resolution.Daily) def OnData(self, slice: Slice) -> None: if self.tp.IsReady: # The current value of self.tp is represented by self.tp.Current.Value self.Plot("TimeProfile", "tp", self.tp.Current.Value) # Plot all attributes of self.tp self.Plot("TimeProfile", "volumeperprice", self.tp.VolumePerPrice.Current.Value) self.Plot("TimeProfile", "profilehigh", self.tp.ProfileHigh.Current.Value) self.Plot("TimeProfile", "profilelow", self.tp.ProfileLow.Current.Value) self.Plot("TimeProfile", "pocprice", self.tp.POCPrice.Current.Value) self.Plot("TimeProfile", "pocvolume", self.tp.POCVolume.Current.Value) self.Plot("TimeProfile", "valueareavolume", self.tp.ValueAreaVolume.Current.Value) self.Plot("TimeProfile", "valueareahigh", self.tp.ValueAreaHigh.Current.Value) self.Plot("TimeProfile", "valuearealow", self.tp.ValueAreaLow.Current.Value)
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
valueAreaVolumePercentage )
Creates a new TimeProfile indicator with the specified name, period and priceRangeRoundOff.
Visualization
The following image shows plot values of selected properties of TimeProfile
using the plotly library.
