Login Page - Create Account

Support Board


Date/Time: Wed, 12 Feb 2025 01:49:08 +0000



barstudydata.csv history length

View Count: 1268

[2020-09-29 23:40:47]
User339214 - Posts: 22
I am generating a csv file (eg A6Z20-BarStudyData.csv) and have set the option 'use number of days to load' in the main chart settings.

What I see is that when sierra chart first starts up and the chart is opened, the csv file is created with the number of days of history I have specified. The file then grows as new records are added as they arrive. What I am wanting is this file to contain a rolling 'x' number of days so it doesn't get too big. If I delete the csv file while sierra chart is still running, I see a new file is re-created immediately, but it has no header row and just continues writing records from where it left off. The only way I can see to achieve what I want is to shut down sierra chart and start again.

I don't want to have to shut down sierra chart every day. Is there a way to get sierra chart to populate the csv with the number of days required if the file doesn't exist (ie I have deleted it with an external program while the exchange is closed) but without having to restart sierra chart?

The 2nd question...

I have selected 'continuous futures contract - volume based rollover, back adjusted' in the chart advanced settings. What will happen to the barstudydata.csv file when the contract rolls over? Will the name of the file change to the forward contract and that one back fill 'x' days? Will the previous file still exist? What happens if the volume 'bounces' between 2 contracts for a few days? Does it just continue with the most recent contract or go back to the previous contract and write to the old csv file?

Thanks in advance
[2020-09-30 00:55:50]
Flipper - Posts: 65
I believe a custom Study written with this function,

sc.WriteBarAndStudyDataToFileEx()

Will rewrite the file on each update with the right settings - AppendOnlyToFile=0 , StartingIndex=0

As for the second question once the volume rollover is triggered it will not revert back to an older contract. And in any case I don't think trading activity does every reappear in an old contract.
[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
[2020-09-30 08:55:56]
Sierra_Chart Engineering - Posts: 18390
How are you accomplishing what you are in post #1. It sounds like you are using Write Bar Data to File study?:
Write Bar Data to File
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2020-09-30 08:56:02
[2020-09-30 09:32:22]
User339214 - Posts: 22
that is correct.
[2020-09-30 20:08:57]
Sierra Chart Engineering - Posts: 104368
. What I am wanting is this file to contain a rolling 'x' number of days so it doesn't get too big.
You need to modify the study to do this:
How to Build an Advanced Custom Study from Source Code

Regarding this:

I have selected 'continuous futures contract - volume based rollover, back adjusted' in the chart advanced settings. What will happen to the barstudydata.csv file when the contract rolls over? Will the name of the file change to the forward contract and that one back fill 'x' days? Will the previous file still exist? What happens if the volume 'bounces' between 2 contracts for a few days? Does it just continue with the most recent contract or go back to the previous contract and write to the old csv file?

You have to manually change the symbol in the case of a continuous futures contract chart. It will not happen automatically. And refer to the documentation here:
Write Bar Data to File

Specifically:
In the case of when the symbol of the chart changes, unless you have set the File Path Input to a specific file name, the output file name will match the current chart symbol and a new file will be created if necessary. Anytime the symbol of the chart changes, or there is a full recalculation, the output file is fully rewritten with all of the data in the chart.

There is only ever one output file for a chart even when that chart is a Continuous Futures Contract chart.

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: 2020-09-30 20:10:11

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

Login

Login Page - Create Account