Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 02:27:38 +0000



Post From: Python for Sierra Chart

[2014-01-09 21:28:05]
vectorTrader - Posts: 86
ONNB,
thanks. I am new to coding and sc coding for that matter. I want to create a function that save the chart at the end of the day at 16:15 each day.
I tried to work with what I saw in other codes, but It just keeps saving continuous png's. I just want it to save once at the end of the day. Can you tell me what I did wrong here? remember im a newbie.

thanks in advance!

SCDLLName("Autosave")

SCSFExport scsf_autosave(SCStudyGraphRef sc)
{
  SCInputRef Time1 = sc.Input[0];
  
   if (sc.SetDefaults)
{
sc.GraphName = "Save Chart Image to File";
sc.StudyDescription = "";
sc.AutoLoop = 1; // true
sc.GraphRegion = 2;
sc.HideStudy = 1;
sc.DrawZeros = 0;
sc.FreeDLL = 1;
  Time1.Name = "Time to Print";
  Time1.SetTime(HMS_TIME(16,15,0));

return;
}
SCDateTime Print_Time(sc.BaseDateTimeIn[sc.Index].GetDate(),Time1.GetTime() );//Set the print time for each day.
SCDateTime Current_Time(sc.BaseDateTimeIn[sc.Index].GetDate(),sc.BaseDateTimeIn[sc.Index].GetTime());//Get the current time
  sc.Subgraph[0][sc.Index]=0; //Flag signal
  if (Current_Time>=Print_Time)
  {
    sc.Subgraph[0][sc.Index]=1; //attempt to flag Print time so it only prints once per day
  }
  else
   return;
  //I want it to print/save at the change of state
  if (sc.Subgraph[0][sc.Index-1]==0 && sc.Subgraph[0][sc.Index]==1)
    {
      sc.SaveChartImageToFile = 1;
      sc.AddMessageToLog("Printed file",true);
    }
  else  
    return;  
}