Support Board
Date/Time: Wed, 05 Feb 2025 17:51:14 +0000
Post From: cumulative sum need help
[2025-01-12 19:20:18] |
User411647 - Posts: 21 |
Hi guys Need help with cumulative sum of two values, when i use sum persist variable that last index value starts 7XXX and each iteration increases or decreases value by hundreds Historical cumulative line looks good, problem is last index value Can anyone help ? sc.AutoLoop = 1 c_SCTimeAndSalesArray TimeSales; sc.GetTimeAndSales(TimeSales); if (TimeSales.Size() == 0) return; int mojIndex = TimeSales.Size(); int OutputArrayIndex = sc.ArraySize; for (int TSIndex = mojIndex - 1; TSIndex >= 0; --TSIndex) { s_TimeAndSales TimeAndSalesRecord = TimeSales[TSIndex]; TimeAndSalesRecord *= sc.RealTimePriceMultiplier; { // Calculate valuesbid and valuesask int& cumulative_sum = sc.GetPersistentInt(1); int cycle_sum = 0; for (int i = 0; i < 30; i++) { cycle_sum += static_cast<int>(valuesBid[i]) - static_cast<int>(valuesAsk[i]); } cumulative_sum += cycle_sum; sc.SetPersistentInt(1, cumulative_sum); Subgraph_BidSize[OutputArrayIndex] = cumulative_sum; } } |
cumulative.jpg / V - Attached On 2025-01-12 19:19:59 UTC - Size: 50.76 KB - 29 views |