• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MatLab interface - How to call Matlab function?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MatLab interface - How to call Matlab function?

    The background

    I’m familiar with Ninjatrader, being able to code directly in C#, although I want to step up my game and get MatLab functions into Ninjatrader.

    I know MatLab interface is not supported but maybe someone on the forum already had the same need and difficulties and will be kind enough to help me out. Would appreciate the assistance very much and this thread could be a step by step explanation of the interface process useful to others.

    The moment where I get an error message is when I am calling my exported matlab function.

    Can anyone provide the line of code I should be using to call the MatLab function considering the attachments I added to the thread?


    Attached the matlab function, word file with images of the steps done and ninja indicator that tries to interface with DLL and gives an error...

    ACFTest.cs

    acf.zip

    MatLab Forum Question to post.doc

    System INFO

    OS Windows 7 professional
    NT 7
    MatLab R2013a (8.1.0.604), Win32


    What I have done so far

    Using the information I found in NT Forum this is what I did to create an example of a custom dll of the open-source MATLAB package spatial-econometrics.com’s ACF(x,k,p) Autocorrelation Coefficient Estimation function:

    • Create .NET 3.5 Custom DLL of ACF Matlab function in “Documents\NinjaTrader 7\bin\custom”
    • MWArray.dll was copied into Documents\NinjaTrader 7\bin\custom
    • Reference MWArray and ACF DLL in Ninjatrader
    • In Ninjatrader code an Indicator, called ACFTest, that uses ACF(x,k,p) function:


    ACFTest Ninja Indicator:


    In Using declarations added:

    using MathWorks.MATLAB.NET.Arrays;
    using MathWorks.MATLAB.NET.Utility;

    using ACF;

    Variable for sample size:

    privateint sampleSize = 100; // Default setting for SampleSize


    OnBarUpdate:

    MWNumericArray data= new MWNumericArray( MWArrayComplexity.Real, MWNumericType.Double, sampleSize);

    for (int idx= 1; idx <= sampleSize; idx++)
    {
    data[idx]= Close[sampleSize - idx];
    }
    But when I try to call ACF function I guess I’m doing something wrong….what I’m doing is:

    MWArray[] argsOut= ACF(data,1,1);


    And I get the error:

    'ACF' is a 'namespace' but is used like a 'variable'


    can anyone show me what I should be doing in the data array?

    MWArray[] argsOut= ?????;

    or is the error somewhere else?


    many thanks
    Paulo
    Last edited by PRibeiro; 01-12-2014, 06:07 PM.

    #2
    Anyone, please?

    Thanks
    Paulo

    Comment


      #3
      Hello Paulo,

      Thank you for your post.

      As you know, this is unsupported and therefore we would not have documentation on this custom extension. However, you can find information on MATLAB at the following link: http://www.mathworks.com/matlabcentr..._thread/299819
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        Hello fellow traders,

        I've also been scouring the internet for ways to integrate matlab functions into NT.
        Here's a link to some useful info https://www.codeproject.com/KB/dotne...ew=Quick&fr=26

        Here is relevant syntax.
        using ACF; //Assuming ACF is the name of your namespace(or .dll file)
        ACF.[YourClass] yourclass = new ACF.[YourClass](); //[YourClass] is named in the deploytool. by default it's Class1
        MWArray[] argsOut= yourclass.[YourFunction](data,1,1); //[YourFunction] is named in the deploytool, by default it's the .m file name

        Comment


          #5
          Did you manage to add such functionality, I would like to know and see the report!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Uregon, Today, 09:08 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by swcooke, Today, 09:09 AM
          0 responses
          2 views
          0 likes
          Last Post swcooke
          by swcooke
           
          Started by Induna, Today, 08:44 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by TangoTX, Today, 08:36 AM
          1 response
          1 view
          0 likes
          Last Post NinjaTrader_Tyler  
          Started by abdullah, 11-15-2017, 08:44 PM
          11 responses
          822 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X