Support Board
Date/Time: Thu, 27 Feb 2025 03:16:16 +0000
Post From: Iterating through past Time and Sales
[2021-04-28 16:29:10] |
User5044343 - Posts: 68 |
I use the below loop to flag certain time and sales transactions and draw them on a 5 second chart. Issue is it only loops through "live" data - meaning from the time the study is added, doesn't draw anything on the chart prior to that. I also feel its not very efficient - study shows it takes about 2400 ms. Whats the best way to approach this? int64_t& LastProcessedSequence = sc.GetPersistentInt64(1); //reset the sequence number on a full recalculation so we start fresh for each full recalculation. if (sc.IsFullRecalculation && sc.Index == 0) LastProcessedSequence = 0; // Get the Time and Sales c_SCTimeAndSalesArray TimeSales; sc.GetTimeAndSales(TimeSales); if (TimeSales.Size() == 0) return; // No Time and Sales data available for the symbol //Set the initial sequence number if (LastProcessedSequence == 0) { LastProcessedSequence = TimeSales[TimeSales.Size() - 1].Sequence; return; } const int threshold = Threshold.GetInt(); // Loop through the Time and Sales. for (int TSIndex = 0; TSIndex < TimeSales.Size(); ++TSIndex) { s_TimeAndSales Record = TimeSales[TSIndex]; Record *= sc.RealTimePriceMultiplier; //do not reprocess previously processed sequence numbers. if (Record.Sequence <= LastProcessedSequence) continue; LastProcessedSequence = Record.Sequence; |