Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Market profile indicator #5891

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions Algorithm/QCAlgorithm.Indicators.cs
Expand Up @@ -1027,6 +1027,57 @@ public MeanAbsoluteDeviation MAD(Symbol symbol, int period, Resolution? resoluti
return meanAbsoluteDeviation;
}

/// <summary>
/// Creates an Market Profile indicator for the symbol with Volume Profile (VOL) mode. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose VP we want</param>
/// <param name="period">The period of the VP</param>
/// <param name="roundoff">The amount of round to the close values</param>
Marinovsky marked this conversation as resolved.
Show resolved Hide resolved
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The Volume Profile indicator for the given parameters</returns>
public VolumeProfile VP(Symbol symbol, int period = 2, decimal roundoff=0.05m, Resolution resolution = Resolution.Daily, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"VP({period})", resolution);
var marketProfile = new VolumeProfile(name, period,roundoff);
RegisterIndicator(symbol, marketProfile, resolution, selector);

if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, marketProfile, resolution);
}

return marketProfile;
}

/// <summary>
/// Creates an Market Profile indicator for the symbol with Time Price Opportunity (TPO) mode. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose TP we want</param>
/// <param name="period">The period of the TP</param>
/// <param name="roundoff">/// How many digits you want to round and the precision. i.e roundoff=0.01 round to two digits exactly.</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The Time Profile indicator for the given parameters</returns>
public TimeProfile TP(Symbol symbol, int period = 2, decimal roundoff=0.05m, Resolution resolution = Resolution.Daily, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"TP({period})", resolution);

if (roundoff <= 0) throw new ArgumentException("Roundoff must be extrictly bigger than zero.");
Marinovsky marked this conversation as resolved.
Show resolved Hide resolved

var marketProfile = new TimeProfile(name, period, roundoff);
RegisterIndicator(symbol, marketProfile, resolution, selector);

if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, marketProfile, resolution);
}

return marketProfile;
}

/// <summary>
/// Creates a new Maximum indicator to compute the maximum value
/// </summary>
Expand Down