Support Board
Date/Time: Wed, 12 Feb 2025 04:58:45 +0000
Post From: barstudydata.csv history length
[2020-09-30 02:16:54] |
Flipper - Posts: 65 |
Actually i just had a play around with that SC function and there seems no setting that will delete the existing file or over write it! So just delete before writing, #include "sierrachart.h" SCDLLName("Custom_Save_Data") SCSFExport scsf_Custom_WriteBarDataToFile(SCStudyInterfaceRef sc) { SCInputRef Input_Separator = sc.Input[0]; SCInputRef Input_UseUTCTime = sc.Input[1]; SCInputRef Input_BarsToSave = sc.Input[2]; //SCInputRef Input_OutputMilliseconds = sc.Input[3]; if (sc.SetDefaults) { sc.GraphName = "Custom Write Bar Data To File"; sc.StudyDescription = "Write Bar Data To File"; sc.GraphRegion = 0; Input_Separator.Name = "Separator"; Input_Separator.SetCustomInputStrings("Comma;Tab"); Input_Separator.SetCustomInputIndex(0); Input_UseUTCTime.Name = "Use UTC Time"; Input_UseUTCTime.SetYesNo(0); Input_BarsToSave.Name = "Bars to Save"; Input_BarsToSave.SetInt(100); sc.TextInputName = "File Path"; sc.AutoLoop = 1; return; } if (sc.IsFullRecalculation || sc.DownloadingHistoricalData) return; // One Time Processing per Bar int& LastBarIndexProcessed = sc.GetPersistentInt(1); if (sc.Index == 0) LastBarIndexProcessed = -1; if (sc.Index == LastBarIndexProcessed) return; LastBarIndexProcessed = sc.Index; SCString OutputPathAndFileName; if (!sc.TextInput.IsEmpty()) { OutputPathAndFileName = sc.TextInput; } else { OutputPathAndFileName = sc.DataFilesFolder; OutputPathAndFileName.Format("C:\\SierraChart\\Data\\%s-BarData.txt", sc.Symbol.GetChars()); } remove(OutputPathAndFileName); n_ACSIL::s_WriteBarAndStudyDataToFile WriteBarAndStudyDataToFileParams; WriteBarAndStudyDataToFileParams.StartingIndex = sc.Index - Input_BarsToSave.GetInt(); WriteBarAndStudyDataToFileParams.OutputPathAndFileName = OutputPathAndFileName; WriteBarAndStudyDataToFileParams.IncludeHiddenStudies = 0; WriteBarAndStudyDataToFileParams.IncludeHiddenSubgraphs = 0; WriteBarAndStudyDataToFileParams.AppendOnlyToFile = 1; WriteBarAndStudyDataToFileParams.IncludeLastBar = 0; WriteBarAndStudyDataToFileParams.UseUTCTime = Input_UseUTCTime.GetYesNo(); WriteBarAndStudyDataToFileParams.WriteStudyData = 0; WriteBarAndStudyDataToFileParams.UseTabDelimiter = Input_Separator.GetInt() == 1; sc.WriteBarAndStudyDataToFileEx(WriteBarAndStudyDataToFileParams); } this will save the last "Bars to Save" number on every new bar started - default setting as lass 100 bars not including the newest bar |