Support Board
Date/Time: Thu, 21 Nov 2024 22:11:15 +0000
Post From: sc.GetStartOfPeriodForDateTime does not work
[2013-04-12 15:32:06] |
GmA - Posts: 20 |
Hello Support board! I have tried to use sc.GetStartOfPeriodForDateTime function, but it always returns incorrect result. Code is the following: #include "sierrachart.h" SCDLLName("Test") SCString MessageString; SCSFExport scsf_Test(SCStudyGraphRef sc) { SCDateTime dtDayStartDateTime; int iYear; int iMonth; int iDay; int iHour; int iMinute; int iSecond; if (sc.SetDefaults) { sc.GraphName = "Test"; sc.FreeDLL = 1; sc.AutoLoop = 1; sc.ScaleRangeType = SCALE_SAMEASREGION; return; } if (sc.GetBarHasClosedStatus(sc.Index)!=BHCS_BAR_HAS_CLOSED) { return; } dtDayStartDateTime = sc.GetStartOfPeriodForDateTime(sc.BaseDateTimeIn[sc.Index], TIME_PERIOD_LENGTH_UNIT_DAYS, 1, 0); dtDayStartDateTime.GetDateTimeYMDHMS(iYear, iMonth, iDay, iHour, iMinute, iSecond); MessageString.Format(" sc.Index = %d, Session Start time = = %.2d.%.2d.%d %.2d : %.2d ", sc.Index, iDay, iMonth, iYear, iHour, iMinute); sc.AddMessageToLog(MessageString,0); } Log looks as follow: Chart: ESM3 30 min #1 | Study: Test | sc.Index = 0, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Chart: ESM3 30 min #1 | Study: Test | sc.Index = 1, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Chart: ESM3 30 min #1 | Study: Test | sc.Index = 2, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Chart: ESM3 30 min #1 | Study: Test | sc.Index = 3, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Chart: ESM3 30 min #1 | Study: Test | sc.Index = 4, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Chart: ESM3 30 min #1 | Study: Test | sc.Index = 5, Session Start time = = 01.01.1950 00 : 00 | 2013-04-12 09:49:25 Same output till sc.Index == 6000. Build log: -- Starting build of Custom Studies Source File: Test.cpp. -- 18:49:18 "C:\SierraChart\CPPCompiler\bin\g++.exe" "C:\SierraChart\SierraChartTransActMA\ACS_Source\Test.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions -o "C:\SierraChart\SierraChartTransActMA\Data\Test.dll" -- End of Build -- 18:49:19 Theere is an old posts were similar problem with that function was described and as a resolution VC compiler were proposed to be used. https://www.sierrachart.com/supportboard/showthread.php?t=40023&highlight=GetStartOfPeriodForDateTime I've tried to compile it by Visual C++ Express, but result is the same. Current version is 961. Please advice how to make it working. Thanks in advance and Br GmA |