Porting from TS 9.1 to MC. EL and PL differences

Questions about MultiCharts and user contributed studies.
RobinT
Posts: 35
Joined: 09 Feb 2015

Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 10 Feb 2015

[Tag] TS OOEL

I am starting a port of a complex autotrading strategy from TS Easylanguage to MC Powerlanguage. I have come across many differences in the first compile. I will list the differences and I would welcome any guidance. The working system can be seen here:



I am going to list all the issues I have come across so far and I welcome suggestions:

I have listed all the issues from the first compile and I would be grateful for any guidance.

constants - not supported, use vars

Code: Select all

constant: int max_cnt (70) ;
vars not support as array parameters

Code: Select all

const: int max_cnt (70) ;
array: int tstop [max_cnt] (0);
have to do - : int tstop [70] (0);

Code: Select all

Using elsystem;
Using elsystem.windows.forms;
Using charting;
using elsystem.io;
Using elsystem.drawing;
Using strategy;
not clear what to do. I presume PL has its equivlents.

PL has no objects, but I just want a windows box to send messages to.

Code: Select all

vars:
Form frmTM( Null ),
Font myfontTM (null),
ListView MEJTTM( Null );
not clear how to get windows box on screen.

Code: Select all

StreamReader reader(NULL),
Streamwriter writer(NULL),
these two objects read and write sequential data to a file.

Code: Select all

ChartingHost ChartingHost1( NULL );
this one just moves the display to a particular date.

Code: Select all

Method void stat ( int res_pt )
it seems PL does not support methods, does this mean only functions with parameter passing?

Code: Select all

setexitonclose
I use this to close all emini futures position at the end of the day. I set the closing time of the CME exchange at -1 min, 16:14 EST which ensures any remaining positions are closed. I can make a custom trading session under TS, can I do this with MC?

I am sure there will be loads more, thanks for your input.
Last edited by RobinT on 10 Feb 2015, edited 1 time in total.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 10 Feb 2015

I have found constant is const and method not supported, need functions.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 10 Feb 2015

truefalse data type not supported, use bool ?

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 10 Feb 2015

PL offers compatibility with the core EL language but compatibility is not 100%. I have programs running on both TS and MC and my preferred platform is MC by a long shot.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Feb 2015

Code: Select all

vars:
Form frmTM( Null ),
ListView MEJTTM( Null );
As I can't use objects, I will need to use text but fix it to a position on the chart. I enclose a picture of what I want to achieve. I have read about Text_float but I can't find that. Can anyone point me to a solution to this. In summary, text fixed to a position on the screen, preferably in a box.
Attachments
mert1-13.JPG
Text Window
(244.26 KiB) Downloaded 2623 times

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Feb 2015

Code: Select all

ChartingHost ChartingHost1( NULL );
I want to be able to move the underlying chart to the specified date.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby Henry MultiСharts » 11 Feb 2015

Hello RobinT,

EasyLanguage Object Oriented programming is not supported in PowerLanguage.
For Object Oriented programming we have MultiCharts .NET (with C# and Visual Basic .NET support).
The differences you list are not applicable when comparing classic EasyLanguage (non Object Oriented) with PowerLanguage.
not clear how to get windows box on screen.
You can utilize the Expert Commentary window to output information. Please see the corresponding reserved words. Otherwise you will need to write your own window and connect it using an external DLL.
these two objects read and write sequential data to a file.
You will need an external DLL for that. You can try this one.
this one just moves the display to a particular date.
Please see ScrollToBar.
I use this to close all emini futures position at the end of the day. I set the closing time of the CME exchange at -1 min, 16:14 EST which ensures any remaining positions are closed. I can make a custom trading session under TS, can I do this with MC?
That is possible to change the symbol session settings or apply a session template to your chart.
1) To change the symbol session settings:
Go to MultiCharts->File->New->QuoteManager window->double click on the symbol you need->Sessions tab->you can modify the session time here. Copy/paste your existing chart / or create a new one / or close-open your workspace to apply the changes in session settings.
Each chart of this symbol set to Default session will use these session settings.
2) To create a custom session template:
Go to MultiCharts->File->New->QuoteManager window->Tools->Session templates.
More information can be found here.
Select your session template on the chart in Format->Instrument->Settings tab->Session.

For closing all positions at the end of the session please see this example.
truefalse data type not supported, use bool ?
Variables can be numerical, string, or true/false.
As I can't use objects, I will need to use text but fix it to a position on the chart. I enclose a picture of what I want to achieve. I have read about Text_float but I can't find that. Can anyone point me to a solution to this. In summary, text fixed to a position on the screen, preferably in a box.
Please see the attached study.
Attachments
Plot_Text_v2.pla
(8.09 KiB) Downloaded 423 times

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Feb 2015

Henry, thanks for all of that, plenty to be getting on with.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Feb 2015

The expert commentary window seems to be the answer. Do I need to create the window in the workspace or can I create the window from pl.

also

I am modifying my EL code to be as similar to PL as possible. I have changed constant to const removed methods and so on. I have vars defined as truefalse in EL, should I make them all bool?

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby TJ » 11 Feb 2015

const = input:

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 12 Feb 2015

const = input:
Thats not the case in TS EL. Input puts an entry in the strategy format window or passes value to functions and const declares a name as a fixed value which cannot be changed by the program.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 12 Feb 2015

I am trying to see if there are any quirks wilth mc functions. I cant search for function. I am interested how once begin is handled.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby Henry MultiСharts » 12 Feb 2015

The expert commentary window seems to be the answer. Do I need to create the window in the workspace or can I create the window from pl.
Expert Commentary window can be launched from a toolbar in MultiCharts.
I am modifying my EL code to be as similar to PL as possible. I have changed constant to const removed methods and so on. I have vars defined as truefalse in EL, should I make them all bool?
That is not mandatory to declare the type of the variable (int/bool). It can be auto detected once you assign a value to it.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 12 Feb 2015

I did extensive compatibility checking of EL and PL. The once-begin construct works as in EL. There are no quirks with functions in PL. You have the same concept of simple and series functions. There is one and only difference I found for functions. In EL, you can alias the function call frequency. In PL all functions are called at the data1 frequency.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby Henry MultiСharts » 12 Feb 2015

In EL, you can alias the function call frequency. In PL all functions are called at the data1 frequency.
That is possible to call the functions on data2 and fix the values on data2 frequency: [FAQ] Data2

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 12 Feb 2015

I have a real problem that is stopping the port. I have a function that is called in 13 different places with loads of variables. Because the parameter passing was long winded I put it in a method that did all the parameter work. That meant there was one set of variables as the function was called from one place. as mc doesn't have methods I was getting rid of methods and just calling the function. This creates a new set of vars for each instance and the function does not work. Is there anyway of making the vars persist and intrabarpersist doesn't do it. Global, public?

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 12 Feb 2015

Henry, indeed the FAQ addresses how to make functions work with data2. There is a subtlety with the function call frequency that is not addressed in the FAQ. Please note this is not an issue for me since I am used to the PL way of doing it. I was just pointing out for the benefit of the new user that this is an area of departure between EL and PL.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 12 Feb 2015

I have a real problem that is stopping the port. I have a function that is called in 13 different places with loads of variables. Because the parameter passing was long winded I put it in a method that did all the parameter work. That meant there was one set of variables as the function was called from one place. as mc doesn't have methods I was getting rid of methods and just calling the function. This creates a new set of vars for each instance and the function does not work. Is there anyway of making the vars persist and intrabarpersist doesn't do it. Global, public?
Perhaps there is a workaround by using call by reference to force the different function instances to see the same parameters. The other option is global variables.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 12 Feb 2015

how does call by reference work in el

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 12 Feb 2015

how does call by reference work in el
EL Essentials Programmers Guide p108

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 14 Feb 2015

Expert Commentary window can be launched from a toolbar in MultiCharts.
thanks, i was wondering if it can be launched from pl.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 16 Feb 2015

how does call by reference work in el
sorry I was thinking of calling the function, you are referring to numericarrayref and stuff like that?

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby JoshM » 16 Feb 2015

how does call by reference work in el
sorry I was thinking of calling the function, you are referring to numericarrayref and stuff like that?
When you create a function, you can declare it's inputs to be passed by reference, like:

Code: Select all

Inputs:
myNumber(NumericRef), // Passed by reference
myOtherNumber(NumericSimple); // Passed as copy
I once wrote a Wiki article about it here: Passing values to and from a function.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 20 Feb 2015

how do you deal with simulated accounts for backtesting?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby Henry MultiСharts » 20 Feb 2015

how do you deal with simulated accounts for backtesting?
Backtesting is done using the chart data only, without any broker connection.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 20 Feb 2015

does it simulate trades?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby Henry MultiСharts » 20 Feb 2015

does it simulate trades?
Yes, it does. On a study calculation in backtesting a set of orders is generated. Orders live until the next study calculation. The orders are not actually sent to the broker, orders do not have any IDs and they cannot be accessed directly. Backtesting results can be seen on the chart and in the Strategy Performance Report. For more information please see Backtesting and How Signals are Calculated.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 20 Feb 2015

great. i'm nearly there, ready to test in a few days.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 25 Feb 2015

I am compiling my el code having laboriously removed all methods, but it seems to reject astype int which is generously sprinkled through my code. Is this supported or should I remove it?

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 25 Feb 2015

also the "transparent"

TL_SetColor(RefHID, transparent);

doesnt compile.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 25 Feb 2015

transparent no longer an issue but astype int is.

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby TJ » 25 Feb 2015

transparent no longer an issue but astype int is.
see post #6
viewtopic.php?f=16&t=6929

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 25 Feb 2015

ok, got it. if you declare a variable int does it have any effect?

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby TJ » 25 Feb 2015

ok, got it. if you declare a variable int does it have any effect?
There used to be a time (I mean >40yrs ago) where the CPU power was not so great, and we had to conserve every bit of available resources for speedy execution.

Today, with the multi-gigahertz multi-core multi-thread multi-CPU and dedicated math processing units, the need to declare int in this environment is not so important anymore. Afterall, you are dealing with decimals in trading 90% of the time.

KISS and you will live long and prosper.

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby TJ » 25 Feb 2015

ps. IIRC, the latest version of MC supports all the formats, but I cannot find the reference at the moment. If you must do it, please contact Tech Support directly for the answer.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 25 Feb 2015

excellent point.

however I have been caught out by actual 0 and 0.0000000000000000001 before, which is <> 0.

comments? in 10000 lines of autotrading code, I don't want to be caught out.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby ABC » 25 Feb 2015

ok, got it. if you declare a variable int does it have any effect?
In MC it doesn't. All variables except Boolean ones are of type double.

Regards,

ABC

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 08 Mar 2015

to compile, now I have to sort out the differences.

I use

pathname = Environment.GetMyWorkDirectory() + "\";

to get the path of the mywork directory. what is the equivalent for mc, and mc64 ?

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby JoshM » 08 Mar 2015

pathname = Environment.GetMyWorkDirectory() + "\";

to get the path of the mywork directory. what is the equivalent for mc, and mc64 ?
There is no equivalent of that in PowerLanguage, probably because MultiCharts doesn't work with work directories -- all studies are kept in a fixed location (which you can find in the 'Directories' tab of the 'Preferences' window, by the way: see here).

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 08 Mar 2015

so if you want it independant of mc and mc64 you have to do

pathname = "C:\Program Files (x86)\TS Support\" ;

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Mar 2015

Hooray, it's nearly all working. I have modified the EL code so the TS and the MC versions are dealt with by versions of a couple of functions.

I have a problem though.

I have set all times to exchange time so es futures start at 0830 and the amended close is 15:14 to setexitonclose works. All works fine. ES is symbol @esh15.d from TS feed.

After the once begin ... end; the very first line of code is:

if time >= 1500 then print (date, " ",time);

and for each day I get:

1150309.00 1505.00
1150309.00 1510.00
1150309.00 1514.00

except yesterday, only get:

1150310.00 1500.00

the signal stops at 1500. The chart has the three bars displayed from 1505 - 1514 so the data is coming through but the software is not running. This is the one thing stopping completion of the software.

Also, someone has asked for the software with a IB interface. Are there some public feed settings so I can test the IB interface or do I need to get an IB account.
Attachments
mert2-10.JPG
(125.16 KiB) Downloaded 2569 times

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby orion » 11 Mar 2015

You likely have a problem with Realtime History Matching (RHM). Turn it off.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Mar 2015

Thank you so much, that was it.

what does RHM do anyway?

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Mar 2015

I am delighted to tell everyone that mertautotrader is working with multicharts and TS as the broker. I need to get a few other brokers tested so if anyone has the details of broker feeds I would be grateful.

Thanks to everyone for their help.

www.mertautotrader.com
Attachments
mc.JPG
(208.19 KiB) Downloaded 2585 times

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 11 Mar 2015

AFter all that work I cant find a broker to connect mc to other than ts!

I have 20 clients looking to move.

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

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby JoshM » 15 Mar 2015

AFter all that work I cant find a broker to connect mc to other than ts!
See Supported brokers and Supported brokers topic. And then there's also Google.

So I'm not sure what you mean with 'I can't find a broker to connect mc to'.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 17 Mar 2015

josh thanks for the link, very useful.

I have a barcharts real time trial and i can't find the instrument.

got cme and cboe but can only find spm5 and no spx.

I need es and spx.

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 24 Mar 2015

I am posting my findings with the different brokers to the supported brokers thread

RobinT
Posts: 35
Joined: 09 Feb 2015

Re: Porting from TS 9.1 to MC. EL and PL differences

Postby RobinT » 24 Mar 2015

what rubbish.

I have found information and am posting it. I was asking Henry and now I am posting the results.

Got anything useful to say?


Return to “MultiCharts”