PDA

View Full Version : Using DLL's in NinjaScript


SigmaTrader
09-22-2006, 05:45 PM
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

NinjaTrader_Dierk
09-22-2006, 10:59 PM
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").

SigmaTrader
09-23-2006, 01:38 AM
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

NinjaTrader_Dierk
09-24-2006, 04:30 AM
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);

SigmaTrader
09-24-2006, 05:01 AM
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.

#region:Define 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.....

NinjaTrader_Dierk
09-24-2006, 05:23 PM
- 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).