I created an array with price and volume of the candle. After that when I try to get the volume for a given price not able to get it even though the key got added to the array.
Its working for /NQ but failing for /CL. can you please let me know if there any limitations with double. I am not able to get the POCPrice from the list eventhough the key present when I lopped through it to find the existing values in the array.
Sample code snippet below,
if(barsType.Volumes[CurrentBars[0]].GetMaximumVolume(null, out price) > 0 ){
POCPrice = price;
}
double ticksAggregation= 4 * TickSize;
Print(Time[0]+ " POCPrice: "+POCPrice +" ticksAggregation: "+ticksAggregation);
//create data dictionary
Dictionary<double, long> kvpArray = new Dictionary<double, long>();
for (double i = Lows[0][0]; i <= Highs[0][0]; i=i+ticksAggregation) // cycle through each tick level
{
long bidVol = barsType.Volumes[CurrentBars[0]].GetBidVolumeForPrice(i);
long askVol = barsType.Volumes[CurrentBars[0]].GetAskVolumeForPrice(i);
Print(Time[0]+ " Adding price and values: "+i+ " bidVol: "+ bidVol+" askVol: "+askVol );
kvpArray.Add(i, bidVol +askVol);
}
foreach (KeyValuePair<double, long> pair in kvpArray)
{
Print(Time[0]+ " Key values : "+ pair.Key +" Value : "+pair.Value);
}
long pocVolume=0;
if(kvpArray.ContainsKey(POCPrice)){
pocVolume= kvpArray[(double)POCPrice];
}else{
Print(Time[0]+ " POCPrice key not present : "+ POCPrice);
}
Comment