Using TWSLink with NinjaTrader

Discuss, post your questions about TWSLink here.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
Casey
Posts: 10
Joined: Thu Sep 14, 2017 8:19 pm

Using TWSLink with NinjaTrader

Post by Casey »

I added TWSLink2.dll as a reference in the NinjaTrader code editor and it gave me the following error:

NinjaScript File Error Code Line Column
<None> Metadata file 'c:\Windows\SysWOW64\twslink2.dll' could not be opened -- 'An attempt was made to load a program with an incorrect format. ' CS0009 0 0

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: Using TWSLink with NinjaTrader

Post by board_admin »

Hello,
i am not familar with NinjaTrader. From what i read on NinjaTrader website, it is based on .NET.
So they expect a .Net assembly DLL not a win32 DLL.

.Net is so called managed code and promoted by Microsoft and intended to make applications more safe and robust.
.Net finally make calls into the win32 API.

TWSLink is a classic win32 API DLL and unmanaged code. In some .Net environments it is possible to call unmanaged code.
We have some C#, VB.Net examples for TWSLink.

https://trade-commander.com/public-downloads/

One project is a .NET assembly which finally uses TWSLink. Perhaps it works when you add this assembly as reference.
(You can build and run all with the Free MS Visual Studio (2017) community edition.)

But it all depends on the possibility by NT to make calls into unmanaged code at all. I can't say this, but may MT support or a guru in their forum.

Casey
Posts: 10
Joined: Thu Sep 14, 2017 8:19 pm

Re: Using TWSLink with NinjaTrader

Post by Casey »

I haven't tested thoroughly, but it appears that importing the DLL will work with NinjaTrader.

e.g.
[DllImport("twslink2.dll")]
public static extern int REGISTER_CONTRACT(string underlying, string sectype, string currency, string exchange, string primexchange, string expiry, string right, double strike, string multiplier, int expired, double mintick);

Post Reply