Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NTMARKETPOSITION = Trouble / Bug
Collapse
X
-
I see the same problem
NinjaTrader_Ray:
I am seeing the same problem that BIGRED. Sometimes I get filled and the order status changes but the NtMarketPosition(Account) stills returns 0 when it should return something <> 0 to indicate the position.
I have the following function in EL:
AtsNTMarketPosition = 0;
If NtConnected(0) Then Begin
Value1 = NtMarketPosition(Account);
If Value1 < 0 Then
AtsNTMarketPosition = -1
Else If Value1 > 0 Then
AtsNTMarketPosition = 1;
End;
It is supposed to return 1/-1/0. When I create a new order I save the order id to a variable and I monitor the status with the function
Status = NtOrderStatus(OrderId).
WHen the status changes:
Status = "Filled" Or Status = "PartFilled" Or Status = "Cancelled" Or Status = "Rejected"
At this moment I call the NtFilled(OrderId) function and correctly reports the amount of contracts filled but the NtMarketPosition returns 0.
At this point I mark the order as filled but since the position is 0 my code send another other. Of course at this point the market position is correctly returned. This problem is intermittent. For example today I got filled 3 orders one filled ok the other two were filled twice. Yesterday I had not problems at all. I seen this problem when I run in NT simulated account as well as now running IB simulated account. No all the orders have this problem and I seeing it happening in all the versions I used. Basically the problem is that when NtStatus changes the MarketPosition needs to be updated at the same time. I could use the NtFilled to workaround but it would just make the whole thing to complex.
Here is the log I print when I run my strategy from TS:
DATE TIME TICK COMPUTERTIME ORDERID LOG
02/29/2008 , 1012 , 68 , 10:11:34 AM , JCP-1080229-1012-68 , PLACE,,100,0.00,0.00,,JCP-1080229-1012-68,SE H1 , MP=0 , Command-Returns=0
02/29/2008 , 1012 , 77 , 10:11:35 AM , JCP-1080229-1012-68 , PROCESSING, status=PendingSubmit , order=SELL-0.00-0.00-100.00 , position= 0 , curent shares= 0
02/29/2008 , 1012 , 78 , 10:11:35 AM , JCP-1080229-1012-68 , PROCESSING, status=PendingSubmit , order=SELL-0.00-0.00-100.00 , position= 0 , curent shares= 0
02/29/2008 , 1012 , 79 , 10:11:35 AM , JCP-1080229-1012-68 , REMOVING, status=Filled , order=SELL-0.00-0.00-100.00 , position= 0 , curent shares= 0 , filled= 100
02/29/2008 , 1012 , 82 , 10:11:35 AM , JCP-1080229-1012-68 , PLACE,,100,0.00,0.00,,JCP-1080229-1012-68,SE H1 , MP=0 , Command-Returns=0
02/29/2008 , 1012 , 82 , 10:11:35 AM , JCP-1080229-1012-68 , REMOVING, status=Filled , order=SELL-0.00-0.00-100.00 , position= 0 , curent shares= 100 , filled= 100
02/29/2008 , 1016 , 23 , 10:15:00 AM , JCP-1080229-1016-23 , PLACE,,100,0.00,0.00,,JCP-1080229-1016-23,SX H Prof 1 , MP=-1 , Command-Returns=0
02/29/2008 , 1016 , 25 , 10:15:03 AM , JCP-1080229-1016-23 , REMOVING, status=Filled , order=BUY-0.00-0.00-100.00 , position= -1 , curent shares= 100 , filled= 100
02/29/2008 , 1018 , 11 , 10:17:07 AM , JCP-1080229-1018-11 , PLACE,,100,0.00,0.00,,JCP-1080229-1018-11,SX H Bailout , MP=-1 , Command-Returns=0
02/29/2008 , 1018 , 12 , 10:17:09 AM , JCP-1080229-1018-11 , REMOVING, status=Filled , order=BUY-0.00-0.00-100.00 , position= 0 , curent shares= 0 , filled= 100
Moscu
Comment
-
This Problem again
Today I have the problem where the order is filled but the NTDirect DLL fails to update the status.
I sent an order at to BUY MEE at 11:01:08 AM when the price was 64.35.
The order was an stop at 64.39 for 400 shares
Here is the fill as reported by IB "Trades" window (The audit trail shows the same times also):
MEE;STK;;;;;BOT;100;64.43;11:01:21;20080826;ISLAND ;
MEE;STK;;;;;BOT;200;64.44;11:01:21;20080826;NYSE;
MEE;STK;;;;;BOT;100;64.44;11:01:21;20080826;NYSE;
Notice from the NT log that the first partial fills are reported relativelly on time "11:01:33" but the last fill of 100 shares is reported on 11:03:14 that is almost 2 min later.
8/26/2008 11:03:14,Position,Instrument='MEE' Avg price=64.4425 Quantity=400 Market position=Long
8/26/2008 11:03:14,Order,New State=Filled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=400 Fill price=64.44
8/26/2008 11:03:14,Execution,Execution='MEE/0001f028.48b42502.01.01' Instrument='MEE' Exchange=Nyse Price=64.44 Quantity=100 Market position=Long
8/26/2008 11:01:33,Order,New State=PartFilled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=300 Fill price=64.44
8/26/2008 11:01:33,Order,New State=PartFilled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=300 Fill price=64.44
8/26/2008 11:01:33,Execution,Execution='MEE/0001f028.48b42501.01.01' Instrument='MEE' Exchange=Nyse Price=64.44 Quantity=200 Market position=Long
8/26/2008 11:01:33,Order,New State=PartFilled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=100 Fill price=64.43
8/26/2008 11:01:33,Order,New State=PartFilled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=100 Fill price=64.43
8/26/2008 11:01:33,Execution,Execution='MEE/0000e69b.48b3f6f7.01.01' Instrument='MEE' Exchange=Island Price=64.43 Quantity=100 Market position=Long
8/26/2008 11:01:33,Order,New State=PartFilled Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=100 Fill price=64.43
8/26/2008 11:01:26,Order,New State=Accepted Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=0 Fill price=0
8/26/2008 11:01:25,Order,New State=PendingSubmit Instrument='MEE' Action=Buy price=0 Stop price=64.39 Quantity=400 Type=Stop Filled=0 Fill price=0
8/26/2008 11:01:25,ATI,AT, 'PLACE;XXXX123;MEE;BUY;400;STOP;0;64.39;DAY;;BUY-MEE-1080826-1101-35-STOP-64.39;;' processingAttached Files
Comment
-
Follow up
I just want to post a new find that I have for those of you having the same problem. I have create to function that mimics the TS functions MarketPosition and CurrentShares with NT calls as follows:
here is the version of MaketPosition
Inputs:
Account(string);
AtsNTMarketPosition = 0;
If NtConnected(0) Then Begin
Value1 = NtMarketPosition(Account);
If Value1 < 0 Then
AtsNTMarketPosition = -1
Else If Value1 > 0 Then
AtsNTMarketPosition = 1;
End;
here is the version of CurrentShares:
Inputs:
TradeAccount(string);
Variables:
Current_Shares(0);
Current_Shares = 0;
If NtConnected(0) Then Begin
Current_Shares = AbsValue(NtMarketPosition(TradeAccount));
End;
AtsNtCurrentShares = Current_Shares;
They call the same NT function therefore they should return similar data. But they do not the MarketPosition returns 0 instead or 1/-1 when the version of CurrentShares is returning a value > 0. Looking at my version the only thing I can see is the use of Value1 in MarketPosition. This might be getting over written some how. So I changed my function to:
Inputs:
Account(string);
Variables:
MP(0);
AtsNTMarketPosition = 0;
If NtConnected(0) Then Begin
MP = NtMarketPosition(Account);
If MP < 0 Then
AtsNTMarketPosition = -1
Else If MP > 0 Then
AtsNTMarketPosition = 1;
End;
This creates a variable MP which is locally initialized to 0.
I hope this help to somebody.
Moscu
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by frankthearm, Today, 09:08 AM
|
5 responses
14 views
0 likes
|
Last Post Today, 10:19 AM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
43 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by yertle, Today, 08:38 AM
|
5 responses
15 views
0 likes
|
Last Post Today, 09:45 AM | ||
Started by adeelshahzad, Today, 03:54 AM
|
3 responses
19 views
0 likes
|
Last Post Today, 09:43 AM | ||
Started by bill2023, Yesterday, 08:51 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 09:37 AM |
Comment