Login Page - Create Account

Support Board


Date/Time: Sat, 10 May 2025 18:21:14 +0000



Post From: learning to code a simple strategy

[2016-01-27 10:23:17]
Sierra Chart Engineering - Posts: 104368
Here is an example which can be used to take action at a particular time. It relies upon a function call which will be out in the next release coming out later today.

SCSFExport scsf_ActionWhenTimeEncountered(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    // Set the configuration and defaults
    
    sc.GraphName = "Action When Time is Encountered";
    
    sc.StudyDescription = "This study function demonstrates performing an action when a certain time is encountered in the most recent chart bar.";
    
    sc.AutoLoop = 1;
    
    sc.FreeDLL = 0;
    
    return;
  }

  
  // Do data processing

  SCDateTime TimeToCheckFor;

  //The first step is to get the current date.
  int CurrentDate = sc.BaseDateTimeIn[sc.ArraySize - 1].GetDate();

  //Apply the time. For this example we will use 12 PM
  TimeToCheckFor.SetDate(CurrentDate);
  TimeToCheckFor.SetTimeHMS(12, 0, 0);

  // TimeToCheckFor is contained within the current bar.
  if (sc.IsDateTimeContainedInBarIndex(TimeToCheckFor, sc.Index))
  {
    //perform the action here
  }
  
}

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