View Full Version : dll function orders.
11-07-2006, 08:42 PM
I have a question regarding the ATI DLL.
Currently writing an external program that will connected to NinjaTrader every now and then, and thus thought that your ATI would do the thing. I am working in a C++ btw.
At the moment I have got all the functions working, I can access individual orders, place them, etc. But the only thing that refuses to work is the function Orders.
currently defined as const char* (__stdcall *OrdersFuncPtr)(char*), which seems to work for every other function.
Can't find any reason why it shouldn't work, and havn't found any information regarding this in the forums or manual.
11-07-2006, 10:24 PM
There is an oddity with functions returning strings (which ties into memory management consideration in C/C++ code): After calling the "Orders" function you need to copy the returned string to a seperate buffer, since the return buffer will be reused on subsequent calls of ATI functions.
The same is true for any ATI function return a "string" (which is in fact a pointer to a char buffer).
11-08-2006, 12:13 AM
Currently running a system with TradeStation delivering orders to NinjaTrader, that passes it along to Interactive Brokers.
I have checked the memory and the function Orders simply doesn't return anything, it doesn't matter which account I use (Sim101 or DU15231). All orders are put by the TS email interface, except for a few which I have place myself through the dll functions. Simply seems like nothing gets written to the memory at all.
Maybe I use it the wrong way, it should generate a long string containing all the orderids of the API generated orders. I have pending orders, filled orders etc. Is it possible that it runs out of bufferspace or something?
Afraid I am a bit at lost here :?
11-08-2006, 03:03 AM
Ahh, I guess I know the issue: You can't mix TS mail interface and calling ATI methods.
"Orders" method only reports orders which are placed through ATI and not the TS mail interface. In fact none of the ATI methods works on orders places through TS mail interface.
11-09-2006, 12:16 AM
Tested to only enter orders by the DLL ATI early today but it still doesn't return anything.
My program is very simple, it places one order that has been hardcoded into the program and then it runs the function Orders. But it is simply the only function that fails to return anything (returns a pointer to the memory allocated by the dll, but its all empty). I included a .zip with the source code just in case.
The problem is that I want to have an external program to monitor what kind of orders that ninjatrader do everyday and then process and put that information on the web. I noticed that NT uses a microsoft access database, which maybe I could use to get the information out from NT, but somehow I rather do it by using the ATI.
11-09-2006, 12:49 AM
This is a timing issue: you need to wait a bit until NT updated the "Orders" information through an NT internal callback.
I suggest doing a "busy wait" (wait and check in a loop), in case you really need to wait until "Orders" returns info the just submitted orders.