How to convert a TS 9.1 code to PowerLanguage code

Questions about MultiCharts and user contributed studies.
User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

How to convert a TS 9.1 code to PowerLanguage code

Postby CrazyNasdaq » 02 Jun 2016

[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;
Attachments
LRChan.zip
(62.7 KiB) Downloaded 154 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

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

Postby TJ » 02 Jun 2016

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.

User avatar
CrazyNasdaq
Posts: 318
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 97 times
Been thanked: 86 times

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

Postby CrazyNasdaq » 02 Jun 2016

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

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

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

Postby JoshM » 03 Jun 2016

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;


Return to “MultiCharts”