Support Board
Date/Time: Mon, 08 Sep 2025 21:32:20 +0000
Post From: Data calculation by every tick
[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); } The question is, what have I mistaken? How those ask/bid volumes are calculated? Thanks, Balazs |