Support Board
Date/Time: Sun, 02 Feb 2025 15:46:44 +0000
Post From: GetSizeAtBarIndex Incorrect
[2019-09-12 06:20:31] |
yellowandy - Posts: 20 |
Hello, I have a study that is looking at bid/ask volume and it appears on occasion that some of the volume entries are missing. It seems to be the lowest entry by price in the bar. My study is currently on a five minute number bar but the lowest price volume element simply isn't there. The code is pretty straight forward and copied below. So again while in one example I saw four price points within that five minutes that had been traded against on the chart but the custom study was reporting back only 3 vap elements. The lowest price one with very low volume (0x2) wasn't being reported. I had logged all of the prices that were being processed and it simply didn't appear. const s_VolumeAtPriceV2 *p_VolumeAtPrice=NULL; int VAPSizeAtBarIndex = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(sc.Index); DebugMessage.Format("VAP BARS TO PROCESS =%d", VAPSizeAtBarIndex); sc.AddMessageToLog(DebugMessage, 0); for (int VAPIndex = 0; VAPIndex < VAPSizeAtBarIndex; VAPIndex++) { if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, VAPIndex, &p_VolumeAtPrice)) break; //TotalVolume += p_VolumeAtPrice->Volume; //Calculate the price. This requires multiplying p_VolumeAtPrice->PriceInTicks by the tick size float Price = p_VolumeAtPrice->PriceInTicks * sc.TickSize; //Other members available: unsigned int AskVolume = p_VolumeAtPrice->AskVolume; unsigned int BidVolume = p_VolumeAtPrice->BidVolume; DebugMessage.Format("Processing price =%f ,bidVolume=%d askVolume= %d", Price,BidVolume,AskVolume); sc.AddMessageToLog(DebugMessage, 0); if(AskVolume == 0 ) { TotalAsksZero++; DebugMessage.Format("Increasing total asks zero %d", TotalAsksZero); sc.AddMessageToLog(DebugMessage, 0); } if(BidVolume == 0 ) { TotalBidsZero++; DebugMessage.Format("Increasing total asks zero %d", TotalAsksZero); sc.AddMessageToLog(DebugMessage, 0); } unsigned int NumberOfTrades = p_VolumeAtPrice->NumberOfTrades; //TotalVolume += AskVolume; } VolumeAtAsk[sc.Index] = (float)TotalAsksZero; VolumeAtBid[sc.Index] = (float)TotalBidsZero; |