Login Page - Create Account

Support Board


Date/Time: Wed, 13 May 2026 01:28:54 +0000



Question about sc.VolumeAtPriceForBars

View Count: 301

[2026-03-23 23:18:20]
Tony - Posts: 715
ACSIL Interface Members - Variables and Arrays: sc.VolumeAtPriceForBars

I have a custom study that store volumes of each level for current session in a array, the size of the array is MyArray[(DaysHigh-DaysLow)/TickSize], if I need to access Volume of current level, I just need to do this: MyArray[(sc.Close[sc.Index]-DaysLow)/TickSize]

Everything works great until today. This morning, due to the volatility of the market, VbP has a gap in 6562.50 - 6571.50 range (roughly), so the sc.VolumeAtPriceForBars skipped those levels, and the size of the array is 36 levels short, and I wasn't able accurately get the number of volume, unless, I temporarily modify the code to fetch the number that is 36 ticks lower.

I tried to modify the sample code as such:
const s_VolumeAtPriceV2 *p_VolumeAtPrice=NULL;
int VAPSizeAtBarIndex = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(sc.Index);
for (int VAPIndex {0} ; VAPIndex<VAPSizeAtBarIndex; VAPIndex++) {
    if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, VAPIndex, &p_VolumeAtPrice))
      ProfileValues[VAPIndex] = 0;
    else
      ProfileValues[VAPIndex] = p_VolumeAtPrice->Volume;
}

but it didn't work, wonder if there is a way to get around this?

Thanks so much!
[2026-03-24 00:54:15]
Tony - Posts: 715
Problem solved, please ignore my original message, Thanks!

const s_VolumeAtPriceV2 *p_VolumeAtPrice=NULL;
int VAPSizeAtBarIndex = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(sc.Index);
memset(ProfileValues, 0, sizeof(ProfileValues));
int LowestTick {(int)round(SessionLowest / sc.TickSize)};
for (int VAPIndex {0} ; VAPIndex<VAPSizeAtBarIndex; VAPIndex++) {
    if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, VAPIndex, &p_VolumeAtPrice))
      break;
    int TargetIndex {p_VolumeAtPrice->PriceInTicks - LowestTick};
    ProfileValues[TargetIndex] = p_VolumeAtPrice->Volume;
}

Date Time Of Last Edit: 2026-03-25 14:19:15

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account