Using MATLAB in cTrader /cAlgo

Created at 17 Feb 2013, 11:37
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DI

dinhero

Joined 17.07.2012

Using MATLAB in cTrader /cAlgo
17 Feb 2013, 11:37


Dear all, 

I am opening this thread as a try to insert MATLAB algorigm in cTrader / cAlgo.

please, you inside/comments and observation are welcome


@dinhero
Replies

hichem
17 Feb 2013, 12:06

RE:
dinhero said:

Dear all, 

I am opening this thread as a try to insert MATLAB algorigm in cTrader / cAlgo.

please, you inside/comments and observation are welcome

What are you trying to achieve ?

You want to reimplement an algorithm written in Matlab in cAlgo with C# ?

You want to communicate data from cAlgo to MATLAB then back to cAlgo ?


@hichem

dinhero
17 Feb 2013, 13:36

begining

so before going too far, you have to know that I have basic Matlab knowlege as well C#, so this is a path we will going to have together;

1. The function

we will start by creating a simple attion function in matlab, which addition the 2 number passed as parameter

function y = simpleAdd(x,z)
%MAKESQUARE Magic square of size x.
%   Y = MAKESQUARE(X) returns a magic square of size x.
%   This file is used as an example for the MATLAB 
%   Builder NE product.

%   Copyright 2001-2007 The MathWorks, Inc.
%   $Revision: 1.1.6.1 $  $Date: 2008/06/24 17:09:41 $

  y = x+z;

we can test the function in matlab 


 


@dinhero

dinhero
17 Feb 2013, 14:04

compiling to C#

2. Compiling the C# code; 

we compile the code  in order to have the .net component, as result we will have the 2 following dll

- simpleA.dll

- simpleANative.dll

now the idea will be to find a way to import it in cAlgo, and to use it in an cBot. 

Of course several prerequies have to be meet : matlab or the MCR have to be install... other prerequises we will find when implementning, you know as this kind of thing is.

 


@dinhero

hichem
17 Feb 2013, 20:18

RE: compiling to C#
dinhero said:

2. Compiling the C# code; 

we compile the code  in order to have the .net component, as result we will have the 2 following dll

- simpleA.dll

- simpleANative.dll

now the idea will be to find a way to import it in cAlgo, and to use it in an cBot. 

Of course several prerequies have to be meet : matlab or the MCR have to be install... other prerequises we will find when implementning, you know as this kind of thing is.

 

Hello,

To add a reference please use the "Add Reference" button on the top menu next to build. You may then locate the dll in your file system and add to your robot/indicator.


@hichem

admin
18 Feb 2013, 11:54

Please refer to the MathWorks website for help on using Matlab with C#.


@admin

dinhero
18 Feb 2013, 21:35

RE:
admin said:

Please refer to the MathWorks website for help on using Matlab with C#.

I already tried, this does not work.

and YOU ? owner/coder/admin of cAlgo, did you test if cAlgo C# was truly compatible with other things? or should be wait. In this case, it would be better just to wait up to your program be mature. 

 


@dinhero

dinhero
18 Feb 2013, 21:36

RE:
admin said:

Please refer to the MathWorks website for help on using Matlab with C#.

I already tried, this does not work.

and YOU ? owner/coder/admin of cAlgo, did you test if cAlgo C# was truly compatible with other things? or should be wait. In this case, it would be better just to wait up to your program be mature. 

Please produce us some real matlab example done by you, 

 

Best regards

 


@dinhero

dinhero
18 Feb 2013, 21:47

RE:
admin said:

Please refer to the MathWorks website for help on using Matlab with C#.

OK, I really like cAlgo, so I will try to give it one more try, ok ?

This is my question in my Matlab path : when I am getting the code to run, cAlgo produce an error, I need to know what this error is, so I can correct it. 

I put a try{}catch bloc in my code, but where can I print this error ? there no console. SO  the question would be how can I write in the cALgo log, so I can read in detail the error ?

{this is a very simple/basic things, MT4 have the "print" function}


@dinhero

dinhero
19 Feb 2013, 06:47

RE: RE:
dinhero said:
admin said:

Please refer to the MathWorks website for help on using Matlab with C#.

OK, I really like cAlgo, so I will try to give it one more try, ok ?

This is my question in my Matlab path : when I am getting the code to run, cAlgo produce an error, I need to know what this error is, so I can correct it. 

I put a try{}catch bloc in my code, but where can I print this error ? there no console. SO  the question would be how can I write in the cALgo log, so I can read in detail the error ?

{this is a very simple/basic things, MT4 have the "print" function}

ok, I get the print to log function, is Print (lol)


@dinhero

dinhero
19 Feb 2013, 06:52

Hi support , can it exist any kind of problem if importing a 64 bit dll ?


@dinhero

dinhero
19 Feb 2013, 06:58

Support, find us a way in cAlgo so we can export or copy the log !!!!


@dinhero

dinhero
19 Feb 2013, 07:05

Support I need your help, here is the error I get :

system.argumentoutofrangeexception startindex cannot be less than zero


this the concerned bloc of code

   try
        {
        
          	  MWNumericArray x= null; 
	          MWNumericArray y= null;
	          MWNumericArray z= null;
          
         	  simpleAC fonction = new simpleAC();
    
          
              x = 9; 
              y = 8;
        
        }catch(Exception e){
        
        Print(e);
        
        }




@dinhero

cAlgo_Fanatic
27 Feb 2013, 14:58

Please post the rest of the code.

Regards,


@cAlgo_Fanatic