Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 04:30:41 +0000



[Programming Help] - GetSizeAtBarIndex Incorrect

View Count: 572

[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;
[2019-09-13 06:25:44]
yellowandy - Posts: 20
I found another instance today where an entire price was skipped, you can see it reported an entry for 3007.00 and 3006.50 but 3006.75 was completely missing.
imageScreen Shot 2019-09-12 at 11.20.46 PM.png / V - Attached On 2019-09-13 06:23:51 UTC - Size: 128.54 KB - 252 views
Attachment Deleted.
[2019-09-13 06:38:36]
Sierra Chart Engineering - Posts: 104368
There is 0% possibility that there is any problem with:
sc.VolumeAtPriceForBars

It presents the very same data that you see with the Numbers Bars study at each chart bar.

It is not within the scope of our support to analyze your code. And it is impossible for us to even analyze this case because we do not see the chart or its data or have access to the data. This is not within the scope of our support.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-09-13 06:56:28

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

Login

Login Page - Create Account