NinjaTrader Support Forum  

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 01-01-2008, 03:55 PM   #1
alekstraj
Junior Member
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default Why NTMarketPosition doesn't work?

I use the DLL functions in EasyLanguage to place automatic orders from TS2000i to NT with GAIN simulated account, and I noticed that NTMarketposition("") does not work, that is no matter what happens it always returns 0. I must say that all orders are submitted via TS i.e. automatically. This was also confirmed via debugging and printing values to separate file using print function in EL.
If one uses statement such as if NTMarketposition("")=1 then begin it won't work, even though NTBuyMarket was successfully submitted previously.
I must mention that i also tried using
If NTMarketposition("Sim101")=1 then begin but with no avail.
alekstraj is offline  
Reply With Quote
Old 01-01-2008, 04:30 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Please use the latest NT 6.5 Beta (available in this support forum) as there have been changes to NTMarketPosition() underlying function. Please let us know if it does not work as you expect.
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-10-2008, 06:07 AM   #3
alekstraj
Junior Member
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Nope, it still does not work as it suppose to.
alekstraj is offline  
Reply With Quote
Old 01-10-2008, 07:00 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Can you try it by specifiying the account name.

Print(NTMarketPosition("Sim101"))

etc...
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-15-2008, 09:25 AM   #5
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

I am seeing the same thing in ver 6.0.1000.8. I always get back a value of zero reguardless of how I call the function.
aslane is offline  
Reply With Quote
Old 01-15-2008, 09:29 AM   #6
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
Default

NT6: You only will see something if you entered the position in the very session you are in.
NT6.5: You even would see something if this position was entered in any session.

-> I suggest updating to latest NT6.5 and trying again: http://www.ninjatrader-support.com/v...ead.php?t=4944
NinjaTrader_Dierk is offline  
Reply With Quote
Old 01-15-2008, 09:56 AM   #7
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

I am seeing this bad behavior in the same session.

I place an order, see it accepted, see it filled, and then I get back zero when calling NTMarketPosition when called with either the account or an empty string.

I am printing this all out in TS as it unfolds over a short interval.
aslane is offline  
Reply With Quote
Old 01-15-2008, 09:58 AM   #8
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
Default

Thanks for feedback. I recommend updating to NT6.5 and trying again.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 01-15-2008, 10:29 AM   #9
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

I installed 6.5, and it performs in the exact same fashion.
aslane is offline  
Reply With Quote
Old 01-15-2008, 11:15 AM   #10
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
Default

Then there is no position for this instrument in NT.

What's the exact name of your TS instrument?
NinjaTrader_Dierk is offline  
Reply With Quote
Old 01-15-2008, 11:30 AM   #11
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

Are you kidding me?

If an order is filled and position is showing up in DOM and it is in the log and it is in everything else in NT, then there is a position.

I am trying to trade the ER2. This is done with the ER2.D symbol in TS, and Instrument "ER2 03-08" in NT.

I use this same setup to successfully enter trades in "live" mode, so I know the instruments etc are not an issue.

The issue I am having is I am trying to use NTMarketPosition for the first time because I am extended a strategy to issue more than one order per day (working strategy only issues a single order per day). I want to block all new orders until the position returns to flat. Everything that I have tried always returns zero from the function call.
aslane is offline  
Reply With Quote
Old 01-15-2008, 11:38 AM   #12
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
Default

TS instrument names with suffix like ".D" do not work as expected. You might want to try ER2 with expiry or the continuous contract.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 01-15-2008, 11:49 AM   #13
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

That was it.

Changing from @er2.d to @er2 in TS caused the NTMarketPosition to start working.

This should be fixed as it is a bug in the symbol name mapping (those two symbols should work the same as they should both be mapped to ER2 front month). Is it easy enough to remove any ".D" postfix before mapping?

This is kind of painful, as I require the ".D" contract for my study.

Thanks for helping figure this out.
aslane is offline  
Reply With Quote
Old 01-15-2008, 11:51 AM   #14
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
Default

Thanks for your suggestion. We'll add it to the list of future considerations.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 01-17-2008, 07:54 AM   #15
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default

If you change the NTMarketPosition EL code to the code below it will function correctly even on ".D" based symbols (works for me on the @ER2.D). The code change basically looks for a ".D" postfix and removes it if present before calling MarketPosition.

DefineDLLFunc: "NtDirect.dll", int, "MarketPosition", lpstr, lpstr;
inputs: Account(string);
vars: vSymbol(GetSymbolName);
if RightStr(vSymbol, 2) = ".D" then vSymbol = LeftStr(vSymbol, StrLen(vSymbol)-2);
NTMarketPosition = MarketPosition(vSymbol, Account);
aslane 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
error NTmarketposition VincentD Automated Trading 5 10-24-2007 08:09 AM
NTMarketPosition in EFS script Oli Automated Trading 3 02-27-2007 04:47 AM
NTMarketPosition could not have been = 0 trickofthetrade Automated Trading 1 03-27-2006 01:17 PM
Synching NTMarketPosition and positions dwil Automated Trading 3 03-24-2006 12:09 AM
NTMarketposition for IB jonno Automated Trading 17 02-24-2006 03:29 AM


All times are GMT -6. The time now is 08:00 PM.