NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 02-02-2006, 02:22 PM   #1
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

I am using Tradestation8 --> IB and wish to check that *IB* does not have a position before I send an order.

I noticed that the NTMarketposition function uses the TRADESTATION "marketposition" command. That will not return the marketposition for Interactive Brokers !

Is there a command that I can use to get the IB marketposition.

Thanks
jonno is offline  
Reply With Quote
Old 02-02-2006, 02:57 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

The function calls a method on the NT DLL called marketposition and is not to be confused with the EL reserved word "marketposition". NTMarketPosition will return what you are looking for.
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-02-2006, 03:29 PM   #3
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post


whilst i havent tried it yet im concerned it will not work, because you have used a TS reserved word which the easylanguage compiler recognises.

for example when i open up the function, the "marketposition" command is highlighted in blue - this means that tradestation has automatically recognised it as a built in TS reserved word.

jonno is offline  
Reply With Quote
Old 02-02-2006, 04:01 PM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

No, it works fine. Check out e.g. NTSample strategy.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 02-02-2006, 09:49 PM   #5
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

ok thanks.
jonno is offline  
Reply With Quote
Old 02-13-2006, 07:40 AM   #6
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Dierk
I had a problem in testing today with NTmarketposition returning zero, for a position that i held in IB.

it was for "IWM" stock symbol.

i was using a print statement to verify that NTmarketposition was returning the correct value. it read as:

print(date,time,NTmarketposition("IWM",""));

the default account was set to be my live IB account which held the position. i am ASSUMING that the account code can be left blank on this call if you are using the default account.

the print statement returned the following output:

1060213.001438.00imktpos=-1 -100.00 0.00

(the -100 is the TS strategy). the 0.00 is what NTmarketposition returned

one thing to mention: i am not receiving market data into IB for IWM. however placing orders via the NT ATI works 100% OK if no checks are being made with regards to NTmarketposition.

can you please let me know if i am doing something wrong or whether perhaps this is a bug in NT ATI

thanks
jonno is offline  
Reply With Quote
Old 02-13-2006, 07:44 AM   #7
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

apologies, i had the wrong piece of code pasted for that routine. it should have been:
.............
NTContracts=NTmarketposition(NTProductCode,"");

print(date,time,"imktpos=-1 ",TSContracts,NTContracts);

{please note that NTProductCode = "IWM"}
jonno is offline  
Reply With Quote
Old 02-13-2006, 08:44 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Jonno,

NTMarketPosition does not take the stock symbol as an argument. Not sure if this is causing the issue.

print(NTMarketPosition(""));

should print out the correct position for the instrument loaded in the TS chart that your strategy is applied to.

Ray

PS - Forgot to add that you are correct in your understanding of the default account use.
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-13-2006, 02:30 PM   #9
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Ray
ray you are right, i had actually changed the P1 parameter in the NTmarketposition function/DLL to be passed in as a string as opposed to the chart based TS EL symbol retrieve that was being done. sorry i also forgot to mention that! no more surprises i promise. :-)

can i request an enhancement that the NTmarketposition function allows you to explicitly pass the product code?

I am trying to do symbol substitution, where when i get a signal on the russell via an applied strategy, i am sending orders for IWM. part of this *requires* position checks on IWM which does not seem possible from the ER2 chart.

i would think that plenty of users will find it useful to be able to pass the product code to the NTmarketposition function call as opposed to hard coded symbol retrieve.

thanks
angus
jonno is offline  
Reply With Quote
Old 02-14-2006, 12:17 AM   #10
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Angus,

Thanks for your suggestion. Will add to list for consideration.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-14-2006, 03:36 AM   #11
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Actually, the underlying DLL function is implemented with symbol/account name. Its just the NTMarketPosition wrapper function that handles it for convenience.

Open up the NTMarketPosition function in EL and create a new one that takes the symbol name as an input.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-23-2006, 03:05 PM   #12
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

i tried that id did not work. appreciate if u can look at this and let me know if i have done something wrong. if not, can u pls let me know when it will be fixed? i am having to resort to TradeBolt in the meantime.

here is the modified wrapper:

{ ** Copyright (c) 2005, NinjaTrader LLC ninjatrader@ninjatrader.com }
DefineDLLFunc: "NtDirect.dll", int, "MarketPosition", lpstr, lpstr;
inputs: Account(string),ProductCode(string);

NTMarketPosition = MarketPosition(ProductCode, Account);

-------------------------------------------------------------------------------------------------------

here is a little test indicator that i applied to a chart:

value1 = NTMarketPosition("IWM",""); {def acct = live account in NT options setup}
{ it also does not work if i explicitly define my
account number as parameter 2 string}
print(date,time,symbol," ",value1);

---------------------------------------------------------------------------------------------------------

here is the print output:

1060224.001300.00IB:KSH6 0.00 <=== you can see that it is not picking up the IB position that currently exists in my live account
1060224.001300.00IB:KSH6 0.00
1060224.001300.00IB:KSH6 0.00

----------------------------------------------------------------------------------------------------------

jonno is offline  
Reply With Quote
Old 02-24-2006, 12:34 AM   #13
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Is Automated Trading Enabled via the File--> menu?
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-24-2006, 01:36 AM   #14
jonno
 
Join Date: Nov 2004
Location: , ,
Posts: 22
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

yes
jonno is offline  
Reply With Quote
Old 02-24-2006, 03:05 AM   #15
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

The MarketPosition function will only return information for positions created through the ATI. The ATI does write all position information to a files (See the file interface section) indpendant if they were created through the ATI or not. This might be an alternate approach.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:56 AM.