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

Using DLL's in NinjaScript

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

    Using DLL's in NinjaScript

    Would someone please provide a simple example of using a dll in calculating an indicator. For example, where in the code are they defined and located? I am familiar with how they are used in the TradeStation easylanguage, but Ninjascript is new to me and i would like to attempt to convert some of my TS code that usesdll's. I've searched this forums posts and haven't found any examples.

    Thanks

    #2
    imported post

    NinjaScript basically just is .NET C# plus a lot of convenience methods.

    -> you can access any DLL as you do it by regular C# coding. I suggest browsing the relevent MS documentation (just scan e.g. www.msdn.com for ".net interop").

    Comment


      #3
      imported post

      Thankyou, Dierk, doing a scan on .net interop is like jumping into another universe for me as I know nothing about C+. I am starting from ground zero with Ninjascript and eventually will learn coding with C+, but for now, all i want to know for example, is when i run Ninjascript to create a new indicator where in the coding and formatting process wouldI place the pushpop dll which in TS EasyLanguage is not an Input: or Variable: . Since Ninjasript is designed for making it quick and easy to define Inputs and Variables and Plots, it would be very helpful if there were a step in the process where it says to define dll's. For example in TS EasyLnguage after the inputs and variablesthe code says

      Inputs:

      Variables:

      DefineDLLFunc: "PUSHPOPDLL", DOUBLE, "POPLAST", LONG, LONG, LONG


      Comment


        #4
        imported post

        Sorry, there is no NinjaScript support for calling DLLs. You have to go through the regular .NET interop. There is no way to get around, since you have to make sure e.g. you type matching is set up correctly.

        Here is quick hint (no guarantee, that his works as expected):
        [System.Runtime.InteropServices.DllImportAttribute( "PUSHPOPDLL.dll")] internal static extern double POPLAST(int par1, int par2, int par3);

        Comment


          #5
          imported post

          Thanks, that is getting there. I spent some time on the w.msdn.com and related url's searching on ".net interop" and C# "sharp" and found pieces of code that gave some clues, but no complete examples that fit what i want to do. It looks like what has to be doneis a new #region above the Variables in the NinjaScript editor has to be created and then within that the dll import info is defined, followed by #endregion. Somehow the code has to know where the dll is located and thenfurther downin the code the information it returns has to be identified and operated on, then finally the plot is created.

          #regionefine Dll

          [dll import info here]

          #endregion

          I have a feeling this is an extremely easy task, but getting past the first few steps in selftutoring is time consuming. It would be extremely helpful to the TS user migrating to NinjaT if it had a built in compiler similar to the one MultiCharts has that will take TS EasyLanguage .ela or .els or .eld text file and compile it into a functioning indicator or strategy. Lots of traders don't want to be programmers.....

          Comment


            #6
            imported post

            - The #region statement is not relevant for proper execution. It's just a way to structure code.
            - Likely your DLL is not found, since it's not in the dirrectory where all your NT dll are (<install>\bin).

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by GussJ, 03-04-2020, 03:11 PM
            15 responses
            3,271 views
            0 likes
            Last Post xiinteractive  
            Started by Tim-c, Today, 02:10 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Taddypole, Today, 02:47 PM
            0 responses
            2 views
            0 likes
            Last Post Taddypole  
            Started by chbruno, 04-24-2024, 04:10 PM
            4 responses
            51 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            10 responses
            403 views
            1 like
            Last Post beobast
            by beobast
             
            Working...
            X