Support Board
Date/Time: Wed, 05 Feb 2025 19:59:50 +0000
Post From: ACSIL export to csv
[2025-01-06 10:50:48] |
User431178 - Posts: 579 |
Your path is not being set correctly. Move the OutputFile config into the setdefaults block, otherwise it is reset to the hardcoded value each time you calcaulte the study. If you want to set the default path then I think it should be the full path, including the drive letter. #include "sierrachart.h" #include <fstream> // For file operations #include <iostream> // For input/output operations SCDLLName("FILE ACSIL"); SCSFExport scsf_FunctionName(SCStudyInterfaceRef sc) { SCInputRef Input_240StoAngle = sc.Input[1]; SCInputRef OutputFile = sc.Input[3]; // Initialization code: Runs once when the study is added to the chart if (sc.SetDefaults) { sc.GraphName = "File Export"; // Name of the study sc.StudyDescription = "A basic example of an ACSIL study."; sc.AutoLoop = 1; // Enables auto-loop mode for processing each bar Input_240StoAngle.Name = "240 Rsi Angle"; Input_240StoAngle.SetChartStudySubgraphValues(0, 0, 0); OutputFile.Name = "Output File"; // Name the input for file path OutputFile.SetPathAndFileName(""); // Set the correct path to the file here return; } // .......... more code } I would probably use manual loop instead of auto loop and move the file open/close operation outside of the main loop, but that's just me. Do you mean to only write to file if the bar is closed? If so, you would change this if (sc.BaseData[SC_CLOSE][sc.Index])
for thisif (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED)
SC_CLOSE is wrong, should be SC_LAST as below (and close is always latest price in bar, so current price is redundant). float openPrice = sc.BaseData[SC_OPEN][sc.Index]; float closePrice = sc.BaseData[SC_LAST][sc.Index]; float highPrice = sc.BaseData[SC_HIGH][sc.Index]; float lowPrice = sc.BaseData[SC_LOW][sc.Index]; |