Using MATLAB in cTrader /cAlgo
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
Replies
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#
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
dinhero
18 Feb 2013, 21:35
RE:
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:
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:
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:
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, 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
hichem
17 Feb 2013, 12:06
RE:
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