Support Board
Date/Time: Sat, 16 Aug 2025 14:57:27 +0000
Post From: ACSIL Calculate Bar Duration in Seconds
[2025-08-15 12:02:13] |
aknsyu71@gmail - Posts: 60 |
To use in your own study // Calculate the duration of the last closed bar in seconds
SCDateTimeMS BarEndDateTime = sc.GetEndingDateTimeForBarIndex(sc.Index - 1); SCDateTimeMS BarStartDateTime = sc.BaseDateTimeIn[sc.Index - 1]; SCDateTimeMS BarDuration = BarEndDateTime - BarStartDateTime + SCDateTime::MICROSECONDS(1); float LastClosedBarSeconds = static_cast<float>(BarDuration.GetTimeInSeconds()); //int64_t LastClosedBarMicroseconds =static_cast<int64_t>(BarDuration.GetAsDouble() * 86400000000.0); // Convert days to microseconds if (LastClosedBarSeconds < 1) {FormulaResult=0;} //if bar is less then a second then ignore |