Page 1 of 1

How to convert a TS 9.1 code to PowerLanguage code

Posted: Jun 02 2016
by CrazyNasdaq
[Tag] TS OOEL


Hi, I've a TS 9.1 code but I can't convert to powerlanguage code due some syntax words not recognized by powerlaguage.
Can some one help me to convert the code if it's possible to convert it ?
Attached there is the ELD file plus the txt file of the code.

The sintax mismatch is about line 218

Thanks in advance

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;

Re: How to convert a TS 9.1 code to PowerLanguage code

Posted: Jun 02 2016
by TJ
Hi, I've a TS 9.1 code but I can't convert to powerlanguage code due some syntax words not recognized by powerlaguage.
Can some one help me to convert the code if it's possible to convert it ?
Attached there is the ELD file plus the txt file of the code.

The sintax mismatch is about line 218

Thanks in advance

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;

Do a search on "Method" or "OOEL", there are previous discussions and workarounds.
This is not EasyLanguage. It is TS's new OOEL extension.

Re: How to convert a TS 9.1 code to PowerLanguage code

Posted: Jun 02 2016
by CrazyNasdaq
For what I've read in this post http://www.multicharts.com/discussion/v ... eclaration, if I'm not wrong, it seems that it can't be translated to powerlanguage due the syntax of TS and its extension

Re: How to convert a TS 9.1 code to PowerLanguage code

Posted: Jun 03 2016
by JoshM

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;