Support Board
Date/Time: Sun, 28 Apr 2024 12:54:03 +0000
Post From: StartReplay() works only for the first chart in the Chartbook
[2019-11-11 06:25:19] |
User634719 - Posts: 4 |
Hi Support team, My goal is to create a study which is able to open more that one chart using OpenChartOrGetChartReference(), apply study collection to each one and make a test using StartReplay(). I faced a following issue: StartReplay() doesn't actually start a replay for the second chart. For the first chart everything is OK and replay starts. Here is my test code: #include "sierrachart.h" SCDLLName("TestReplay") SCSFExport scsf_TestReplayStudy(SCStudyInterfaceRef sc) { SCString msg; SCInputRef ReplaySpeedRef = sc.Input[1]; if (sc.SetDefaults) { sc.AutoLoop = 1; sc.GraphRegion = 0; ReplaySpeedRef.Name = "Chart replay speed"; ReplaySpeedRef.SetFloat(250); return; } int& SecondChartOpened = sc.GetPersistentInt(0); if (SecondChartOpened == 0) { s_ACSOpenChartParameters OpenChartParameters; OpenChartParameters.PriorChartNumber = 2; OpenChartParameters.ChartDataType = INTRADAY_DATA; // DAILY_DATA OpenChartParameters.Symbol = "MSFT"; OpenChartParameters.IntradayBarPeriodType = IBPT_DAYS_MINS_SECS; OpenChartParameters.IntradayBarPeriodLength = 1*SECONDS_PER_MINUTE; OpenChartParameters.DaysToLoad = 0; int rc = sc.OpenChartOrGetChartReference(OpenChartParameters); if (rc != 0) { sc.AddMessageToLog(msg.Format("chart #%d opened for MSFT", rc), 0); } SecondChartOpened = 1; SCDateTime& dt = sc.GetPersistentSCDateTime(3); dt = sc.CurrentSystemDateTime; return; } // Uncomment to start replay for the chart #1 /*int& FirstReplayStarted = sc.GetPersistentInt(1); if (FirstReplayStarted == 0) { SCDateTime dt; dt.SetDate(sc.GetCurrentDateTime().GetDate()); dt.SetTimeHMS(8, 0, 0); dt.SubtractDays(5); int rc = sc.StartChartReplay(1, ReplaySpeedRef.GetFloat(), dt); sc.AddMessageToLog(msg.Format("StartChartReplay return value: %d", rc), 0); FirstReplayStarted = 1; return; }*/ // Start replay for the chart number #2 int& SecondReplayStarted = sc.GetPersistentInt(2); if (SecondReplayStarted == 0) { SCDateTime dt; dt.SetDate(sc.GetCurrentDateTime().GetDate()); dt.SetTimeHMS(8, 0, 0); dt.SubtractDays(5); int rc = sc.StartChartReplay(2, ReplaySpeedRef.GetFloat(), dt); sc.AddMessageToLog(msg.Format("StartChartReplay return value: %d", rc), 0); SecondReplayStarted = 1; return; } } Am I doing smth wrong? Any feedback would be greatly appreciated. Date Time Of Last Edit: 2019-11-11 22:10:51
|