Login Page - Create Account

Support Board


Date/Time: Wed, 05 Feb 2025 21:50:12 +0000



Post From: Does anyone know how to format the file pathway for exporting to csv file

[2025-01-31 09:15:40]
seandunaway - Posts: 316
#include <sierrachart.h>

SCDLLName("write bar data to file")
SCSFExport scsf_write_bar_data_to_file (SCStudyInterfaceRef sc)
{
  SCInputRef file = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.DisplayStudyName = 0;
    sc.GraphName = "write bar data to file";
    sc.GraphRegion = 0;

    char user_directory[MAX_PATH];
    ExpandEnvironmentStrings("%USERPROFILE%", user_directory, MAX_PATH);

    char default_file[MAX_PATH];
    snprintf(default_file, MAX_PATH, "%s\\Desktop\\%s.csv", user_directory, sc.Symbol.GetChars());

    file.Name = "file";
    file.SetPathAndFileName(default_file);

    return;
  }

  n_ACSIL::s_WriteBarAndStudyDataToFile WriteBarAndStudyDataToFileParams;
  WriteBarAndStudyDataToFileParams.StartingIndex = sc.CurrentIndex;
  WriteBarAndStudyDataToFileParams.OutputPathAndFileName = file.GetPathAndFileName();
  sc.WriteBarAndStudyDataToFileEx(WriteBarAndStudyDataToFileParams);
}

2025-01-31 01:11:36.187 | ESH25-CME [C][M] 5 Min #1 | Beginning export of bar and study data to file C:\Users\sean\Desktop\ESH25-CME.csv

Date, Time, Open, High, Low, Last, Volume, # of Trades, OHLC Avg, HLC Avg, HL Avg, Bid Volume, Ask Volume
2025-1-21, 13:15:00.000000, 6088.00, 6089.25, 6087.00, 6088.50, 2104, 1238, 6088.19, 6088.25, 6088.13, 1038, 1066


edit: i just saw there is already an included study which does exactly this 🤣
Write Bar and Study Data To File
Date Time Of Last Edit: 2025-01-31 10:20:22