I'd like to know how I can calculate the correct volume@price for a given period.
So for instance, I'd like to calculate the total volume for each price that was traded during 9.30-16.15.
I've tried the following for each bar:
Dictionary<string, double> d_prices = new Dictionary<string, double>();
private bool get_all_price_volume_pairs_for_current_bar()
{
double ticksize = Bars.Instrument.MasterInstrument.TickSize;
double high = Bars.GetHigh(CurrentBar);
double low = Bars.GetLow(CurrentBar);
double theprice = 0;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[2].BarsType as//Bars.BarsSeries.BarsType as
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
for(double price = high;price >= low; price -= ticksize)
{
double volume = barsType.Volumes[CurrentBar].GetTotalVolumeForPrice(price);
if (volume == 0)
continue;
if(d_prices.ContainsKey(price.ToString()))
{
d_prices[price.ToString()] += volume;
} else {
d_prices.Add(price.ToString(),volume);
}
}
return true;
}
However, this doesn't seem to get me exactly the correct volume for say 200 bars if I measure with other indicators.
Anyone who can help me please?
Thanks!
Bo
Comment