Login Page - Create Account

Support Board


Date/Time: Sun, 07 Sep 2025 19:11:59 +0000



[Programming Help] - Data calculation by every tick

View Count: 197

[2025-08-08 12:28:52]
User358514 - Posts: 13
Hey!

I am working on a study which analyzes the delta(ask-bid) volume dynamics inside of a bar.
What is the most efficient(performance approach) way to analyze the tick-by-tick data inside of a bar?
The chatgpt says there is a "sc.NewVolume" variable, but I can't find any info about it, and it isn't in the headers(at least in my version).

Thanks
[2025-08-11 11:01:23]
DFromeaux - Posts: 19
Hi,

I think the best way to do this is to access the intrabar volume using the function:

sc.VolumeAtPriceForBars

This way, you can retrieve the Bid and Ask for each price and either calculate the delta per price level for each bar or sum all the bids and all the asks to calculate the delta for the entire bar.

Here is the documentation: ACSIL Interface Members - Variables and Arrays: sc.VolumeAtPriceForBars
[2025-08-11 17:00:43]
Sierra_Chart Engineering - Posts: 20829
Yes post #2 is good information.

Not sure what else we can suggest without knowing the precise details of the calculations you need to do.
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2025-08-11 17:00:51
[2025-09-01 11:40:05]
User358514 - Posts: 13
Hey again,

I started to test an approach which fits the target drafted above.
I use manual looping and the code below getting called on every study call.

if(index >= sc.ArraySize-1) {
// Get the Time and Sales
c_SCTimeAndSalesArray TimeSales;
sc.GetTimeAndSales(TimeSales);
int TimeSalesSize = TimeSales.Size();

int BeginIndex = 0, EndIndex = 0;
sc.GetTimeSalesArrayIndexesForBarIndex(index, BeginIndex, EndIndex);
SCString DebugString;
DebugString.Format("Time and Sales index = %d, BeginIndex = %d, EndIndex = %d", index, BeginIndex, EndIndex);
sc.AddMessageToLog(DebugString, 0);

DebugMessage.Format("ts size: %d", TimeSalesSize);
sc.AddMessageToLog(DebugMessage, 0);

if (TimeSalesSize == 0)
return; // No Time and Sales data available for the symbol

// Loop through the Time and Sales
int OutputArrayIndex = sc.ArraySize;
uint32_t AskVolume=0, BidVolume=0, Volume=0;
for (int TSIndex = BeginIndex; TSIndex <= EndIndex; TSIndex++)
{
s_TimeAndSales TimeAndSalesRecord = TimeSales[TSIndex];
TimeAndSalesRecord *= sc.RealTimePriceMultiplier;
AskVolume += TimeAndSalesRecord.AskSize;
BidVolume += TimeAndSalesRecord.BidSize;
Volume += TimeAndSalesRecord.Volume * sc.MultiplierFromVolumeValueFormat();
//float Volume = TimeAndSalesRecord.Volume * sc.MultiplierFromVolumeValueFormat();

TimeAndSalesRecord.DateTime.GetDateTimeYMDHMS(tickYear, tickMonth, tickDay, tickHour, tickMinute, tickSecond);
DebugMessage.Format("tick data: %d-%d-%dT%d:%d:%d - %d - %d - %d", tickYear, tickMonth, tickDay, tickHour, tickMinute, tickSecond, AskVolume, BidVolume, Volume);
sc.AddMessageToLog(DebugMessage, 0);
}
sc.BaseDateTimeIn[index].GetDateTimeYMDHMS(tickYear, tickMonth, tickDay, tickHour, tickMinute, tickSecond);
DebugMessage.Format("bar data: %d-%d-%dT%d:%d:%d - %d - %d - %d", tickYear, tickMonth, tickDay, tickHour, tickMinute, tickSecond, AskVolume, BidVolume, Volume);
sc.AddMessageToLog(DebugMessage, 0);
}
I compared the output of this with the built-in "Numbers Bars Calculated Values" study but my study shows much higher of every kind of volume than the built-in solution.

The question is, what have I mistaken? How those ask/bid volumes are calculated?

Thanks, Balazs

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

Login

Login Page - Create Account