Login Page - Create Account

Support Board


Date/Time: Fri, 29 Mar 2024 02:37:34 +0000



StartReplay() works only for the first chart in the Chartbook

View Count: 1162

[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
[2019-11-12 04:48:08]
Sierra Chart Engineering - Posts: 104368
There may be a problem with starting a replay for a chart that was just opened programmatically. You probably would have to delay the start of the replay until that chart actually opens up which would be after the study function returns.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-11-12 04:48:26
[2019-11-12 06:24:44]
User634719 - Posts: 4
My study returns after call to OpenChartOrGetChartReference() and calls StartChartReplay() function next time it's executed. Or I should somehow call StartReplay() in 5, 10, 20 seconds after the second chart has been opened?
[2019-11-18 17:53:43]
Sierra Chart Engineering - Posts: 104368
We need time to test this.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-11-18 20:44:13]
User634719 - Posts: 4
In my test the value of delay depends on whether data for the symbol has been downloaded earlier.
In one case 5 second delay worked for me, but in other case I had to increase it to 10 seconds (I didn't use the symbol before and even didn't have .scid file for it).
[2019-12-04 05:39:12]
Sierra Chart Engineering - Posts: 104368
We have had a look at this, and we have added this to the documentation:
It is not possible to start a replay on a chart which is still in the process of loading data from the chart data file. There will be no error returned but the replay will not start.

So a delay is necessary. What you can do is wait for this function to return a nonzero number: sc.IsChartDataLoadingCompleteForAllCharts
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account