Support Board
Date/Time: Tue, 22 Apr 2025 02:57:47 +0000
Post From: Converting From MetaTrader EA (Init, DeInit, OnTick) to Sierra Chart study?
[2025-02-18 17:44:52] |
seandunaway - Posts: 348 |
@LTSystems, i doubt you're really wanting another thread here is a more concrete example, that matches your metatrader question #include <sierrachart.h>
#define timer_interval_ms 5000 void OnInit (SCStudyGraphRef sc) { sc.AddMessageToLog("OnInit", 1); } void OnDeinit (SCStudyInterfaceRef sc) { sc.AddMessageToLog("OnDeinit", 1); } void OnTimer (SCStudyInterfaceRef sc) { sc.AddMessageToLog("OnTimer", 1); // add logic to get position data every 5 seconds here } void OnTick (SCStudyInterfaceRef sc) { sc.AddMessageToLog("OnTick", 1); } SCDLLName("concepts") SCSFExport scsf_concepts (SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "concepts"; sc.GraphRegion = 0; sc.UpdateAlways = 1; return; } // OnInit int& initialized = sc.GetPersistentIntFast(0); if (!initialized) { OnInit(sc); initialized = 1; } // OnDeinit if (sc.LastCallToFunction) OnDeinit(sc); // OnTimer SCDateTimeMS& last_datetime = sc.GetPersistentSCDateTimeFast(0); SCDateTimeMS now = sc.CurrentSystemDateTimeMS; if (now >= last_datetime + SCDateTime::MILLISECONDS(timer_interval_ms)) { OnTimer(sc); last_datetime = now; } // OnTick OnTick(sc); } Date Time Of Last Edit: 2025-02-18 17:45:37
|