View Full Version : NTMarketPosition suddenly returned a wrong value
Hi,
I'm using eSignal with NT and real IB account. My EFS script checks the NTMarketPosition every time it has a trading signal and makes a trade only if I'm flat. It was working fine for a couple of weeks, but suddenly I've got a double size of my possition (I was not flat and additional trade happened). It could happened only if NTMarketPosition returned a wrong value. Any ideas?
Thanks!
NinjaTrader_Vincent
01-30-2006, 03:50 AM
Hi,
Please send an email directly from within NT5 under Help--> Mail to Support and refer to this topic.
Vince
Hi Vince,
It says: "Failed to send mail. The transport failed to connect to the server".
Then, I swithced off the XP Firewall, but got the same result. I have a hardware router, but I can bypass it only in the evening. (if that is the problem)
NinjaTrader_Vincent
01-30-2006, 06:55 AM
Hi,
Please send a normal email to support and then attach the log.
The log can be found here:
C disk--> Program Files--> NinjaTrader5--> Log--> log.20060130
Don't forget to refer to this topic!
Vince.
I've sent the log.
Thanks!
NinjaTrader_Vincent
01-30-2006, 08:51 AM
Thank you. I've also replied to it.
Vince
Hi,
Does NTMarketPosition uses files that have today's
date as a name(or part of it) to store its information?
The mentioned below problem occures when NT was started prev day then reloaded the next day with open position. It seems that in this case it is just "forgets" about the possition because it's in another file.
Thanks.
NinjaTrader_Ray
03-07-2006, 01:36 AM
The issue has to deal with limitations of the ATI and how accouns are mapped internally. If you carry a position overnight, you need to initialize the ATI. The only way this can be done is by placing and order. I suggest placing an order well below the market and then cancelling it. Then the NTMarketPosition() will return the value you are looking for.
This is on our list to address with no ETA at this time.
Ray
Should this order be placed through ATI only or I can do it manually in NT?
Thanks.
NinjaTrader_Ray
03-07-2006, 06:38 AM
Through ATI.
Does this initialization need to be done for each position or will initializing with one order take care of all?
Thanks.
NinjaTrader_Ray
03-14-2006, 05:10 AM
No, only for each account that you plan to trade against.
Ray
Have you fixed it in Verstion 5.1.1.4 Beta? I saw the following: "Fixed: ATI information was not available immediately when DLL was loaded for TradeStation/eSignal integration" or it's something else?
Thanks.
NinjaTrader_Ray
03-14-2006, 01:10 PM
Not related, you must still initialize.
I am finding that most of my positions come back correctly from NTMarketPosition(), but that some do not. This is even after orders have been filled in otherstocks in that account. The number of shares owned will come back correctly once an order is filled in that particular stock, but not if an order is placed and then cancelledfor that stock. It does not seem to be not limited to a particular set of stocks as after a restart a different set may be incorrect. I am running the latest NT version.
NinjaTrader_Ray
03-21-2006, 02:29 AM
Willlook into this.
One more issue you might want to look into:
When one has a short position and a long position simultaneously, NTMarketPositon returns zero despite the fact that there are stop and target orders submited by NT Strategy for every position. Let me know if you need more explanation of this situation.
NinjaTrader_Ray
03-22-2006, 07:24 AM
The issue reported by dwil was resolved by re-creating an IB connection. This was because we had a depcrated feature surrounding market data on IB connections. This was overriding the new default settings.
BCA, is the market position flat when you have strategies both long and short simultaneously? If yes, then this is accurate. It will report the actual position held in your account. If you want to know the position the strategy holds then I sugges to use the NTStrategyPosition() function.
Ray
Ray,
Does NTStrategyPosition() have the same issue with overnight positions as NTMarketPosition does?
If the name of my Strategy US_Long, should I use NTStrategyPosition(US_Long) or NTStrategyPosition("US_Long")?
Thanks!
NinjaTrader_Ray
03-23-2006, 02:08 AM
No it should not.
NTStrategyPosition("US_Long")
When does NTStrategyPosition go from flat to not flat? Does it happened when I place an order with the Strategy or when this order becomes filled?
Also, Does NTStrategyPosition go flat immediately after the position is closed?
Thank you!
NinjaTrader_Ray
03-23-2006, 04:28 AM
When an order is filled.
When the position strategy position is closed.
It looks like NTStrategyPosition() always returns 0 (flat), no matter what my possition is. I'm using Tradestation. Although, I had a possition with the strategy placed by NTCommand, NTStrategyPosition returned zero.
NinjaTrader_Ray
03-24-2006, 06:58 AM
Dwil/BCA,
We are making some changes to the code to ensure that you will always be able to access the NTMarketPosition and NTStrategyPosition without having the requirement to initialize the ATI. Should have a custom installer available for you to test early next week.
Ray
NinjaTrader_Ray
03-27-2006, 07:48 AM
Can you test the following version:
www.ninjatrader-support.com/ninjatrader/nt5.custom/NinjaTrader.Install.msi (http://www.ninjatrader-support.com/ninjatrader/nt5.custom/NinjaTrader.Install.msi)
Please uninstall then install. There is no longer a need to initialize the ATI. Let me know if this resolves all the reported issues.
Ray
I tried it this morning before the market openedand am still getting zeros for positions that are seen in NT and IB.
NinjaTrader_Dierk
03-28-2006, 12:40 AM
a) You did install custom build below, no?
b) Which instrument was the position on?
Yes, I uninstalled and then followed the link below to re-install. The positions wereabout a dozenmid-cap equity positions.
NinjaTrader_Dierk
03-28-2006, 06:33 AM
Please provide a name of at least one equity instrument where the position was not visible. I want to reproduce on our account here.
NinjaTrader_Dierk
03-29-2006, 06:27 AM
You need to make sure that Tool->Options->ATI->Default account is set to whatever account your are monitoring (here you IB live account and not "SIM101").
I have not noticed any problems with this release.
Thanks!
By the way, I see a lot more Tradestation "switches" under Options/ATI/Tradestation menu. Are you going to integrate NT and TS closer? Will it be possible to pick up orders from TS TradeManager?
NinjaTrader_Ray
04-03-2006, 12:42 PM
Yes, there is a new email based interface. Check out the Help Guide. Full information there.
I made my live IB paper trade account the default as you suggested. Leveled my positionsand thenmade some trades to hold overnight. Overnight NT came back with msg saying I needed to restart because of connection lost. I did that and re-connected to the IB paper trade account. I checked the values of NTStrategyPosition()in Tradestation at this point and they were correct, but I suspect cached. I restarted Tradestation and when I came back in NTStrategyPosition() would give only zeros for positions found in NT and IB.
NinjaTrader_Ray
04-07-2006, 02:02 AM
Were there strategies running? If NT connects and orders are missing strategies won't be recovered.
Hopefully this is the problem. I am sending orders using the NTCommand with an empty string for the NTTemplate and NTStrategy parameters. Is it necessary that both these be filled in with some value? I do not see a use for me at this point for creating an NT strategy, but is there something I need to do with regard to that to make it work?
NinjaTrader_Ray
04-07-2006, 02:22 AM
If you are not trading with strategies then the NTStrategyPosition() function is useless. Go for the NTMarketPosition() function. Leaving the strategy template/id fields empty is fine.
Sorry for the confusion. I am using NTMarketPosition() in all of my code. That is what is retuning zeros overnight.
NinjaTrader_Ray
04-07-2006, 05:25 AM
Please always use an account name in your strategy.
NTMarketPosition("YourAccountName");
Sorry to tell you, but it seems that NTStrategyPosition() is always flat. It still doesn't reflect what a strategy is doing.
I do always use an account name in the call to NTMarketPosition, e.g.,
SharesOwned = NTMarketPosition(iAccountID)
BCA wrote: Sorry to tell you, but it seems that NTStrategyPosition() is always flat. It still doesn't reflect what a strategy is doing.
It would be nice to get some feedback from you for this issue:
Have you got the same bug with NTStrategyPosition as I described?
Are you going to fix it in future releases? (When?)
Thank you!
NinjaTrader_Ray
04-12-2006, 11:35 AM
Hi BCA,
We can not reproduce it. Thats why we are stuck. It works in our test cases and we have no other open reports of this not working so we are kind of stuck.
Ray
This relates to NTMarketPosition. I have found it to be consistently incorrect (returns zeros) when shutting down my computer over the weekend and returning on Monday. I hope this helps with your testing, because I would very much like to see the problem fixed.
vjsworld
05-22-2008, 10:01 AM
I have been trading live for the last three days (just started) using Tradestation to Ninjatrader via the dll. I call NTMarketPosition("myacctnumber") in the code to determine how many contracts I am in, to throw my exits. For the last three days, my code has worked perfectly. Today, the same code returns only zeros for NTMarketPosition. I tried to reboot, etc., to no avail.
HELP!!!
NinjaTrader_Dierk
05-22-2008, 11:02 AM
Sorry, would not know what causes this.
Please double check that you are on 6.5.1000.2.