4.7.6 Volume Profile

From MultiCharts
Revision as of 04:25, 6 May 2013 by Roman MultiCharts (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

All indicators and signals have access to Volume Profile which can be plotted on the chart for the instrument. Profile collection for the main symbol is available via the VolumeProfile property or any symbol through a data stream via the VolumeProfileByDataStream(int DataNumber) method.


Example: The Volume Profile is plotted for the main symbol. Here Volume Profile consists of profiles plotted for every 10 bars of the symbol:

VolumeProfile.png

Profile collection is presented by the folowing interface:

public interface IProfilesCollection : IDisposable
{
	ICollection<IProfile> Items { get; } //Profiles list
 
	bool Visible { get; } //true – profiles are plotted, false – no profiles and collection is empty 
 
	event TProfilesChanged EChanged; //event for receiving the notifications about modification of profile collection 
	IProfile ItemForBar(int bar); // returns the profile on bar number. Bar number should be absolute, starting with 0 (0-based). Acces to the absolute bar number can be gained via Bars.FullSymbolData.Current-1
}

Profile modification Event handler:

namespace PowerLanguage.VolumeProfile
{
	public delegate void TProfilesChanged(bool _full);
}
Example: the study will be recalculated if volume profile has changed:
private void VolumeProfileOnEChanged(bool full)
{
	if (full)
		this.ExecControl.Recalculate();
}
protected override void StartCalc() {
	VolumeProfile.EChanged += VolumeProfileOnEChanged;
}


Interface with the Profile information:

public interface IProfile

  • decimal AboveVAValue { get; } - Cumulative volume on all the levels higher then the highest limit of Value Area(VA)
  • Pair<int> BarsInterval { get; } - The numbers of start and end bars of the profile (first, second]
  • decimal BelowVAValue { get; } - Volumes sum on the levels lower than the lowest limit of the VA
  • Price Close { get; } - Profile closing price
  • bool Empty { get; } - true – then Profile is empty
  • ILevel MaxDelta { get; } - Level with the maximal difference between Buy - Sell (ASK traded - BID traded)
  • ILevel MinDelta { get; } - Level with the minimal difference between Buy - Sell (ASK traded - BID traded)
  • Price Open { get; } - Profile opening price
  • ILevel POC { get; } - POC level (Point Of Control)
  • decimal TotalValue { get; } - Cumulative volume on the profile
  • ICollection<ILevel> VA { get; } - Collection of levels between the highest and the lowest limits of VA
  • ICollection<ILevel> Values { get; } -Profile levels collection
  • decimal VAValue { get; } - Cumulative volume of the levels between the highest and the lowest limits of VA
  • Price HighVAForBar(int bar); - Price of the highest VA level for the bar
  • Price LowVAForBar(int bar); - Price of the lowest VA level for the bar
  • Price POCForBar(int bar); - POC level price for the bar


The Profile level description interface:

public interface ILevel : IEquatable<ILevel>

  • decimal AskTradedValue { get; } - Cumulative volume of all ASK traded trades for the level
  • decimal BidTradedValue { get; } - Cumulative volume of all BID traded trades for the level
  • Price Price { get; } - Level price
  • decimal TotalValue { get; } - Cumulative volume of the level


An example of indicator that plots the minimal and the maximal VA levels:
[SameAsSymbol(true)]
public class VA_Min_Max : IndicatorObject {
	public VA_Min_Max(object _ctx):base(_ctx){}
 
	private IPlotObject max_VA;
	private IPlotObject min_VA;
 
	protected override void Create() {
		max_VA = AddPlot(new PlotAttributes("MaxVA", EPlotShapes.Line, Color.Red, Color.Black, 2, 0, true));
		min_VA = AddPlot(new PlotAttributes("MinVA", EPlotShapes.Line, Color.Blue, Color.Black, 2, 0, true));
	}
	protected override void StartCalc() {
//subscribing for profile changes 
		VolumeProfile.EChanged += VolumeProfileOnEChanged;
	}
 
	protected override void CalcBar()
	{
		int bn = Bars.FullSymbolData.Current-1;
		var vp = VolumeProfile.ItemForBar(bn);
		if (vp != null)
		{	
			max_VA.Set((double)vp.HighVAForBar(bn).Dbl );
			min_VA.Set((double)vp.LowVAForBar(bn).Dbl );
		}
	}
	private void VolumeProfileOnEChanged(bool full)
	{
		//Recalculate if the profile has been completely changed. 
		if (full)
			this.ExecControl.Recalculate();
	}
}


After compilation, enable Volume Profile for the instrument on the chart. Then, insert this indicator into the chart. Now it’s possible to see how the maximal and minimal VA levels changed within Volume Profile.

VolumeProfile2.png