Support Board
Date/Time: Mon, 24 Feb 2025 01:01:55 +0000
Post From: reseting calculation every day
[2021-02-23 21:33:25] |
User907968 - Posts: 833 |
No need to over-complicate this, and you don't have to use a persistent variable (unless you really want to). SCDateTime TradingDayStartDateTime = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.IndexOfLastVisibleBar]); SCString s = sc.FormatDateTime(TradingDayStartDateTime).GetChars(); auto StartIndex = sc.GetFirstIndexForDate(sc.ChartNumber, TradingDayStartDateTime.GetDate()); if (sc.Index == startIndex) { // perform reset actions if necessary } if (sc.Index >= startIndex) { // evaluate bars here } I wouldn't personally use the code as you have it above, but I'm saying that without any real context as to what you are doing with your study and its requirements. An alternative approach for determinining a reset condition based on trading sessions is presented used in "Cumulative Delta Bars - Volume" found in studies8.cpp. Date Time Of Last Edit: 2021-02-23 21:36:42
|