Support Board
Date/Time: Sun, 08 Sep 2024 01:36:21 +0000
[Programming Help] - Programming Help. Acsil Open a chartbook.
View Count: 375
[2023-10-05 14:50:48] |
User178526 - Posts: 4 |
Hello, I have chart with a study i wrote to open another chartbook daily at a specified time. But when its run, it doesn't open the specific chartbook. I've attached my code and also error message from the log. Can anyone tell me what is causing the error, and how to fix it? // The top of every source code file must include this line
#include "sierrachart.h" // For reference, refer to this page: // Advanced Custom Study Interface and Language (ACSIL) // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("Open Chartbook") SCSFExport scsf_OpenChartBookAtTimeAndDay(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Open Chart Book at Time and Day"; sc.StudyDescription = "This study opens a specific chart book at 10:27 AM EST from Monday to Friday."; sc.AutoLoop = 0; // This study will only run once. // Define your inputs for the study. sc.Input[0].Name = "Chart Book Name"; // Name of the chart book you want to open. sc.Input[0].SetString("Daily_Stat"); // Replace with your chart book's name. return; } // Get the current date and time. SCDateTime currentDateTime = sc.CurrentSystemDateTime; // Get the current day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday). int currentDayOfWeek = currentDateTime.GetDayOfWeek(); // Calculate the target time (10:15 AM EST) as seconds since midnight. int targetTimeInSeconds = (10 * 3600) + (27 * 60); // Calculate the current time as seconds since midnight. int currentTimeInSeconds = currentDateTime.GetTimeInSeconds(); // Check if it's a weekday (Monday to Friday) and the current time is 10:15 AM (EST). if (currentDayOfWeek >= 1 && currentDayOfWeek <= 5 && currentTimeInSeconds == targetTimeInSeconds) { // Open the specified chart book when the conditions are met. sc.OpenChartbook(sc.Input[0].GetString()); } } Opening chartbook C:\SierraChart\Data\Daily_Stat. ACSIL function requested to open the chartbook. | 2023-10-05 10:27:00.117
Daily_Stat Daily #11 | Reloading chart. | 2023-10-05 10:27:00.188 Daily_Stat Daily #11 | Non 8-bit characters in text file. Data must be ASCII. | 2023-10-05 10:27:00.192 * Daily_Stat Daily #11 | Error opening or reading chart data file. File: C:\SierraChart\Data\Daily_Stat.Cht | 2023-10-05 10:27:00.193 * Opening chartbook C:\SierraChart\Data\Daily_Stat. ACSIL function requested to open the chartbook. | 2023-10-05 10:27:00.336 Daily_Stat Daily #12 | Reloading chart. | 2023-10-05 10:27:00.415 Daily_Stat Daily #12 | Non 8-bit characters in text file. Data must be ASCII. | 2023-10-05 10:27:00.419 * Daily_Stat Daily #12 | Error opening or reading chart data file. File: C:\SierraChart\Data\Daily_Stat.Cht | 2023-10-05 10:27:00.420 * |
[2023-10-07 18:44:25] |
ForgivingComputers.com - Posts: 928 |
Could it be this? sc.OpenChartbook() wants the file extension: sc.Input[0].SetString("Daily_Stat.cht"); // Replace with your chart book's name.
|
[2023-10-10 14:24:24] |
User178526 - Posts: 4 |
Thanks for your suggestion. But I tried it with the extension, and it still doesn't work. I made sure the chartbook is in the data folder as well.
|
[2023-10-10 16:02:59] |
ForgivingComputers.com - Posts: 928 |
Non 8-bit characters in text file. Data must be ASCII.
This is saying that it doesn't like the file contents. Have you tried opening another chartbook? |
[2023-10-18 13:24:23] |
User178526 - Posts: 4 |
This is saying that it doesn't like the file contents. Have you tried opening another chartbook?
Thank you, that gave me ideas to try, maybe somehow the chartbook is corrupted. I recreated the chartbook and used simple name with no underscore etc... in the filename. That worked!. Thanks again. |
To post a message in this thread, you need to log in with your Sierra Chart account: