Hi all,
I have found details about Volume profile in the Reference guide for MC.NET. (thx for it) I would like to write an indicator(histogram) which displays volume delta for one bar. I think it is possible via Volume Profile when VP is setup for bar.I have found MaxDelta and MinDelta levels and I feel that I can read values through it. There is no possibility to get Delta for Bar. Howto do it? Should I use:
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
and calculate all volumes through all levels in the bar? How to get level ID's which are in the current bar? Is there any easier way to do it?
Thank you
mirek
Volume Delta as histogram [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Volume Delta as histogram
Hello mirek,
Have you checked all of the Volume Profiles interfaces described at this page? Please have a look at IProfile.Values
Have you checked all of the Volume Profiles interfaces described at this page? Please have a look at IProfile.Values
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Volume Delta as histogram
Please find a sample code attached.
- Attachments
-
- Test_ILevelInfo.pln
- (1.26 KiB) Downloaded 932 times
Re: Volume Delta as histogram
Hi Henry,
thx a lot code. It helped a lot. I have written something like this:
It is plotted like the picture in the attachment.
I hope it helps to someone else. If there is a better way to code it, pls. let me know. I am ready to learn.
Thank you
mirek
thx a lot code. It helped a lot. I have written something like this:
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using PowerLanguage.VolumeProfile;
namespace PowerLanguage.Indicator{
public class _Volume_Stats : IndicatorObject {
public _Volume_Stats(object _ctx):base(_ctx){}
private IPlotObject Min_Delta;
private IPlotObject Max_Delta;
private IPlotObject Delta_Total;
public Color plusColor = Color.Green;
public Color minusColor = Color.Red;
protected override void Create() {
Min_Delta = AddPlot(new PlotAttributes("MaxDelta", EPlotShapes.Histogram, Color.Red, Color.Black, 2, 0, true));
Max_Delta = AddPlot(new PlotAttributes("MinDelta", EPlotShapes.Histogram, Color.Green, Color.Black, 2, 0, true));
Delta_Total = AddPlot(new PlotAttributes("DeltaTotal", EPlotShapes.Histogram, minusColor, 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);
decimal _deltaTotal=0;
decimal _maxAsk =0;
decimal _maxBid = 0;
Color _bar_color ;
foreach (VolumeProfile.ILevel _pcol in vp.Values)
{
_maxAsk = _maxAsk + _pcol.AskTradedValue;
_maxBid = _maxBid + _pcol.BidTradedValue;
_deltaTotal = _maxAsk - _maxBid;
}
decimal max_delta = vp.MaxDelta.TotalValue;
decimal min_delta = vp.MinDelta.TotalValue;
if (vp != null)
{
Max_Delta.Set((double)max_delta );
Min_Delta.Set((double)min_delta );
_bar_color = minusColor;
if ( _deltaTotal > 0) _bar_color = plusColor;
Delta_Total.Set((double)_deltaTotal, _bar_color);
}
}
private void VolumeProfileOnEChanged(bool full)
{
//Recalculate if the profile has been completely changed.
if (full)
this.ExecControl.Recalculate();
}
}
}
I hope it helps to someone else. If there is a better way to code it, pls. let me know. I am ready to learn.
Thank you
mirek
- Attachments
-
- DeltaMM.PNG
- (49.06 KiB) Downloaded 1551 times
Re: Volume Delta as histogram
Hi all,
I closed MC.NET yesterday and restarted it today and I can not run my indicator. There is attached error. Can someone help?
Thank you
mirek
I closed MC.NET yesterday and restarted it today and I can not run my indicator. There is attached error. Can someone help?
Thank you
mirek
- Attachments
-
- _Volume_Stats_error.PNG
- (35.62 KiB) Downloaded 1480 times
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Volume Delta as histogram
Have you applied your study before the Volume Profile was loaded?Hi all,
I closed MC.NET yesterday and restarted it today and I can not run my indicator. There is attached error. Can someone help?
Thank you
mirek
1. You need to apply your study to the chart after the Volume Profile is loaded.
2. Before referencing Volume Profile fields you need to make sure they are not NULL.
Re: Volume Delta as histogram
I had VP and my study enabled in the desktop. I have closed MC.NET and I have started it again the next day. The VP has been properly loaded and my study has reported the error.
I have tried to disable study, disable VP and enable VP(with disabled study), wait till VP was fully loaded and then I have reenabled the study. It failed with the same error.
I do not think it is convenient to disable/delete studies each time when MC.NET is closed and reenable them when MC.NET is started and VP is fully loaded.
Anyway I will give it a try as a temporary workaround.
mirek
I have tried to disable study, disable VP and enable VP(with disabled study), wait till VP was fully loaded and then I have reenabled the study. It failed with the same error.
I do not think it is convenient to disable/delete studies each time when MC.NET is closed and reenable them when MC.NET is started and VP is fully loaded.
Anyway I will give it a try as a temporary workaround.
mirek
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Volume Delta as histogram
mirek, did you make sure in the code that the Volume Profile fields are not NULL before utilizing them?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Volume Delta as histogram [SOLVED]
Zen-Fire provides historical tick ask and bid data only for the last trading session. Please make sure you have enough ask and bid tick data in your data base that covers the chart data range. You can also try using a different volume profile setting that does not utilize ask/bid data (up/down tick).
-
- Posts: 53
- Joined: 18 Feb 2011
- Has thanked: 11 times
- Been thanked: 13 times
Re: Volume Delta as histogram - also Bid / Ask Volume within Footprint VolumeProfile
First a shout out to -->> Henry, Thanks, I found an example solution you put on forum to get at ILevels - bid/ask volume. It has taken me a few times to read it to understand it. But I have to admit, I would have never figured that out on my own. It is my lack of C# general knowledge. Now I know how to get at ASK & Bid Volumes with the bar.
Suggestions I think it would be helpful for others to have that as a 2nd example up in the WiKi . 4.7.6 Volume Profile. Also would it be helpful to have the structures also listed in this area? 4.7.5.2 Collections Elements.
Any way - it is a journey as I am self learning C#. I have an old programming degree, and no formal learning on OO, just online stuff. I like the Msft Bob Tabor lessons on C# general stuff. For examples of things specific to MC.Net, where is the best place to find examples? As a resource Visual Studio as the ability to search entire solution. So I search on possible keywords involved in whatever I am looking for. ex - VolumeProfile.
A wish, and I will add it to project mgmt - is to have many more examples, snippets, to be included in the supplied indicators , studies ... They could be in a sub folder to distinguish from other type of code.
John
Suggestions I think it would be helpful for others to have that as a 2nd example up in the WiKi . 4.7.6 Volume Profile. Also would it be helpful to have the structures also listed in this area? 4.7.5.2 Collections Elements.
Any way - it is a journey as I am self learning C#. I have an old programming degree, and no formal learning on OO, just online stuff. I like the Msft Bob Tabor lessons on C# general stuff. For examples of things specific to MC.Net, where is the best place to find examples? As a resource Visual Studio as the ability to search entire solution. So I search on possible keywords involved in whatever I am looking for. ex - VolumeProfile.
A wish, and I will add it to project mgmt - is to have many more examples, snippets, to be included in the supplied indicators , studies ... They could be in a sub folder to distinguish from other type of code.
John