Skip to main content

Data Access — mzVolumeProfile

Demonstrates how to access volume profile data from StrategyVolumeProfileIndicator with Minute accuracy. On each bar close, the strategy prints developing POC, VAH, VAL, and VWAP values for the current session profile.

Source: [INSTALL PATH]/API/Samples/DataAccess_mzVolumeProfile_MinuteAccuracy.cs Class: DataAccess_mzVolumeProfile_MinuteAccuracy : MZpackStrategyBase

Indicator Setup

volumeProfileIndicator = new StrategyVolumeProfileIndicator(this, @"VolumeProfile")
{
Calculate = Calculate.OnBarClose,
ShowProfileType = ProfileType.VP,
ProfileAccuracy = ProfileAccuracy.Minute,
ProfileCreation = ProfileCreation.Session,
POCMode = LevelMode.Developing,
VAHVALMode = LevelMode.On,
VWAPMode = VWAPMode.DynamicStdDev1,
ProfileWidthPercentage = 20,
Values1KDivider = false,

// No stacked profiles
StackedProfileCreation1 = ProfileCreation.None,
StackedProfileCreation2 = ProfileCreation.None,
StackedProfileCreation3 = ProfileCreation.None
};

Important configuration in State.Configure:

Calculate = Calculate.OnBarClose;  // Minute accuracy requires OnBarClose
volumeProfileIndicator.ModelIncrementRefresh = ModelIncrementRefresh.HistoricalRealtime;
// Required to get historical data in backtesting

Accessing IVolumeProfile

The strategy uses OnBarUpdate (not OnBarCloseHandler) because it accesses volumeProfileIndicator.Profiles:

protected override void OnBarUpdate()
{
base.OnBarUpdate();

if (BarsInProgress == 0)
{
IVolumeProfile last = volumeProfileIndicator.Profiles.LastOrDefault()
as IVolumeProfile;

if (last != null)
{
// Detect new session profile
if (last != current)
{
// Print totals for previous profile
if (current != null)
{
Print(string.Format("TOTALS Volume: {0}; Delta: {1}; " +
"High: {2}; Low: {3}",
current.Volume, current.Delta,
current.High, current.Low));
}
}

// Print developing values
Print(string.Format("{0} VAH: {1}; VAL: {2}; POC: {3}; VWAP: {4}",
Time[0], last.VAH, last.VAL, last.POC, last.VWAP));

if (last != current)
current = last;
}
}
}

Available Data

PropertyTypeDescription
last.POCdoublePoint of Control price
last.VAHdoubleValue Area High
last.VALdoubleValue Area Low
last.VWAPdoubleVolume-Weighted Average Price
last.VolumelongTotal profile volume
last.DeltalongTotal profile delta
last.HighdoubleProfile high price
last.LowdoubleProfile low price

Profile Accuracy

ProfileAccuracyUpdate FrequencyUse Case
MinuteOn bar closeBacktesting, historical analysis
TickOn each tickReal-time precision

With ProfileAccuracy.Minute, set Calculate = Calculate.OnBarClose on both the strategy and the indicator.

Profile Creation Modes

ProfileCreationDescription
SessionNew profile each session
DailyNew profile each day
WeeklyNew profile each week
CustomManual profile management
NoneDisabled

See Also