Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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, 07: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

      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


            #6
            If this is still relevant - write - I will tell you how to do it

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,607 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            9 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            19 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            6 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            16 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X