Code: Select all
{ Methods declaration }
var: elsystem.Timer Timer1( NULL );
Method override void InitializeComponent()
begin
Timer1 = new elsystem.Timer;
Timer1.Interval = CalcSeconds * 1000;
Timer1.AutoReset = true;
Timer1.Enable = true;
Timer1.Name = "Timer1";
Timer1.elapsed += Timer1_Elapsed;
(Disclaimer: I don't use TS myself, but their OOEL is heavily based on .NET so my answer comes from that latter framework. This means you'll need to check and test whatever I say here, since I might be quite wrong.
).
Looking at this code it creates a timer event that's triggered every number `CalcSeconds` seconds. When that time elapsed, it seems the `Timer1_Elapsed` event is executed. I don't see here what that event does (this will be defined in the full code to my understanding), but let's say it prints the current computer time to the output window of the PowerLanguage Editor.
Now that we know what it does, it's quite straightforward to translate it to PowerLanguage. Since we don't use timers in MultiCharts but the
RecalcLastBarAfter() keyword, we can rewrite that code to:
Code: Select all
RecalcLastBarAfter(CalcSeconds * 1000);
// Execute the event's code when the periodic
// time-based recalculation happens
if (GetAppInfo(aiCalcReason) = CalcReason_Timer) then begin
Print("The time now is: " + CurrentTime_s);
end;