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

adding custom library to NT

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

    adding custom library to NT

    Hello

    I have built my own dll with matlab (.Net assembly) and would like to add it to NT.

    I registered this dll in GAC by creating a strong name and copying it to C:\WINDOWS\assembly. MWArray is also registered in GAC.

    Now I want to call this dll from strategy. I think I need to add this line before I can use my dll:

    using mylib.dll;

    I did this but when I compile the code, I get this "namespace is not found, are you missing a using directive or assembly reference".

    Do I have to add my custom dll somewhere in NT, do I have to specify the path somehow, why GAC assemblies are not accessible from NT?

    Please suggest at least starting point for fixing this problem.

    Thank you,
    Sergey.

    #2
    Hello Sergey,

    Thanks for the post. Custom assemblies should be stored in:
    Documents\NinjaTrader 7\bin\custom

    Add a reference to this file from a NinjaScript code editor. Right Click > Reference > Add > Select your file.

    After doing the above, restart NinjaTrader and then you should have access.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by sergeysamsonov View Post
      Hello

      I have built my own dll with matlab (.Net assembly) and would like to add it to NT.

      I registered this dll in GAC by creating a strong name and copying it to C:\WINDOWS\assembly. MWArray is also registered in GAC.

      Now I want to call this dll from strategy. I think I need to add this line before I can use my dll:

      using mylib.dll;

      I did this but when I compile the code, I get this "namespace is not found, are you missing a using directive or assembly reference".

      Do I have to add my custom dll somewhere in NT, do I have to specify the path somehow, why GAC assemblies are not accessible from NT?

      Please suggest at least starting point for fixing this problem.

      Thank you,
      Sergey.
      Did you put your classes into a named namespace?

      If so, then you need a using directive for that namespace.

      After that, add a reference for your dll by right-clicking in any indicator/strategy, and using the context menu.

      Comment


        #4
        Sergey,

        Did MatLab create an MWArray.dll file for you, and then another file xxx.dll file?

        Both of those need to be placed in the NT custom folder as mentioned and then references set for them.

        In addition, accessing MatLab, I had to include the using statements (like koganam mentioned) as follows:

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

        Hope this helps.
        VT
        Integrated Trading Technologies - Customized Tools For Trading
        Last edited by VTtrader; 09-19-2011, 05:49 PM.

        Comment


          #5
          Thank you for reply. 50% of the problem is solved. I added a custom made dll to references and then added "using mylib.dll" and it compiled. MWArray.dll was not created but I found it in C:\Program Files\MATLAB\R2010a\toolbox\dotnetbuilder\bin\win3 2\v2.0\. I copied it to custom folder and added to references and then added three "using MathWorks. " statements, when I compile I get an error: Metadata file 'c:\Documents and Settings\...\My Documents\NinjaTrader 7\bin\Custom\MWArray.dll' could not be opened -- 'Error importing module 'ManagedCPPAPI.netmodule' of assembly 'c:\Documents and Settings\...\My Documents\NinjaTrader 7\bin\Custom\MWArray.dll' -- The system cannot find the file specified.

          If you do not mind can you please give me an example how to declare and call matlab function declared in my library?

          Thank you,
          Sergey.

          Comment


            #6
            Sergey,

            Here's what I did to the best of my memory (I have since changed OSs to W7), if this doesn't help I can boot into my old XP install and check further. Some are duplicates from previous post.

            I have placed the MWArray.dll in my NT\custom folder, I also have the "<MyMatlabLibrary>.dll" file that MatLab created in that same NT\Custom folder.

            References are set for both using the NT editor.

            In the indicator/s that calls (uses) the MyMatlabLibrary.dll, I have the following "using" declarations:
            using MathWorks.MATLAB.NET.Arrays;
            using MathWorks.MATLAB.NET.Utility;
            using MathWorks.MATLAB.NET.ComponentData;
            using <MyMatlabLibrary>;

            Then also within the indicator in OnBarUpdate() I have this:

            Code:
             
            MWNumericArray data= new MWNumericArray( MWArrayComplexity.Real, MWNumericType.Double, length);
            for (int idx= 1; idx <= length; idx++)
            {
                data[idx]= Close[length - idx];
            }
            Then:
            MWArray[] argsOut = <Call your library method here>;
            edit: MWNumericArray "data" from above is passed into the method call.

            and finally:
            Output.Set((double)(MWNumericArray)argsOut[X][X]);

            That is the basic format I used anyway.

            Hope it helps.
            VT
            Integrated Trading Technologies - Customized Tools For Trading
            Last edited by VTtrader; 09-19-2011, 08:35 PM.

            Comment


              #7
              Thank you VT! I solved this problem by removing MWArray from custom folder and referencing original MWArray located in Matlab folder.

              Sergey.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by benmarkal, Today, 12:52 PM
              2 responses
              13 views
              0 likes
              Last Post benmarkal  
              Started by f.saeidi, Today, 01:38 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by FAQtrader, Today, 12:00 PM
              3 responses
              14 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by frankthearm, 04-18-2024, 09:08 AM
              15 responses
              63 views
              0 likes
              Last Post frankthearm  
              Started by habeebft, Today, 01:18 PM
              0 responses
              3 views
              0 likes
              Last Post habeebft  
              Working...
              X