Login Page - Create Account

Support Board


Date/Time: Tue, 22 Apr 2025 02:45:38 +0000



Post From: Converting From MetaTrader EA (Init, DeInit, OnTick) to Sierra Chart study?

[2025-02-17 20:36:06]
cmet - Posts: 690
These might point you in the right direction.

OnInit() - sc.SetDefaults
OnDeinit() - sc.LastCallToFunction
OnTick() - sc.UpdateStartIndex
OnTimer() - if there's a built in timer function in ACSIL, I don't know what it is. Probably have to count manually.

Maybe something like this:

SCSFExport scsf_ModifiableTimer(SCStudyInterfaceRef sc)
{
SCInputRef IntervalSeconds = sc.Input[0];

if (sc.SetDefaults)
{
sc.GraphName = "Custom Timer Function";
sc.AutoLoop = 0;
sc.UpdateAlways = 1;

IntervalSeconds.Name = "Interval)";
IntervalSeconds.SetInt(10); // interval (10 seconds)
IntervalSeconds.SetIntLimits(1, 3600); // max interval

return;
}

static SCDateTime LastExecutionTime;
SCDateTime CurrentTime = sc.CurrentSystemDateTime;
int Interval = IntervalSeconds.GetInt();

if (CurrentTime.GetTimeInSeconds() - LastExecutionTime.GetTimeInSeconds() >= Interval)
{
ExecuteTimedFunction();
LastExecutionTime = CurrentTime; // Reset
}
}