Login Page - Create Account

Support Board


Date/Time: Fri, 20 Sep 2024 02:57:56 +0000



Post From: DateTime to Index

[2014-08-22 01:10:28]
vegasfoster - Posts: 444
You can see here http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetNearestMatchForSCDateTime and here http://www.sierrachart.com/index.php?page=doc/doc_SCDateTime.html

An example would be if you wanted daily open then could do something like,


SCSubgraphRef DailyOpen = sc.Subgraph[0];

SCSubgraphRef ReferenceIndex = sc.Subgraph[10];  
  
  if (sc.SetDefaults)
  {
    sc.GraphName = "Daily Open";            
    sc.AutoLoop = true;

    DailyOpen.Name = "Daily Open";
    DailyOpen.LineWidth = 1;
    
    sc.Input[0].Name = "Hour";
    sc.Input[0].SetInt(9);

    sc.Input[1].Name = "Minute";
    sc.Input[1].SetInt(30);
    
    return;
  }

  int Year = sc.BaseDateTimeIn[sc.Index].GetYear();
  int Month = sc.BaseDateTimeIn[sc.Index].GetMonth();
  int Day = sc.BaseDateTimeIn[sc.Index].GetDay();
  SCDateTime DateTime(Year, Month, Day, sc.Input[0].GetInt(), sc.Input[1].GetInt(), 0);

  int InputIndex = sc.GetNearestMatchForSCDateTime(sc.ChartNumber, DateTime);
  ReferenceIndex[sc.Index] = sc.BaseDateTimeIn[sc.Index-1] < DateTime && sc.BaseDateTimeIn[sc.Index] >= DateTime ? InputIndex : ReferenceIndex[sc.Index-1];
  
  DailyOpen[sc.Index] = sc.Open[ReferenceIndex[sc.Index]];

Date Time Of Last Edit: 2014-08-22 01:11:39