Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Workaround for In-Fight execution
Collapse
X
-
Hello bosajin,
You want to know when an order has a cancellation submitted but was filled and the order was an entry order?
With AtmStrategy methods you can check that the order state is CancelSubmitted but then goes back to Filled instead of Cancelled using GetAtmStrategyEntryOrderStatus().
Or you could use the addon approach and attach a handler to the OrderUpdate event and check that the order.OrderState is OrderState.CancelSubmitted then OrderState.Filled.
-
Hi Chelsea B,
I am trying to find another one, meanwhile would you please advice me to catch all open-positions which are made by In-Fight execution.
Leave a comment:
-
Hello bosajin,
2020-09-24 03:36:33:570|1|4|Chart Trader close position
This is from manually clicking the Close button on Chart Trader. This is does not appear when using AtmStrategyClose().
You can see working orders on the Orders tab of the Control Center. You can see open positions on the Positions tab of the Control Center.
Leave a comment:
-
Hello bosajin,
To avoid an inflight execution you would need to know what is causing the in-flight-execution.
This is why I have asked you for clarification before attempting to give an answer.
As an example, lets say you are submitting a CancelOrder() without checking the state of the order first. The order has already filled and then the broker gets your cancel order request. They write back we can't this order there has been an inflight execution and the order cannot be cancelled error disables the script.
To prevent this I would recommend checking the state of an order to still be working before calling CancelOrder(), but this may not completely prevent an in-flight-execution if an order fills after you have checked the state at the same time an cancel is being requested.
To help lower the chances of an in-flight-execution the latency to the brokerage servers should be as low as possible. Cutting down on the communication time reduces something happening on the brokerage servers before your next communication is received. A VPS located next to the brokerage may have much lower latency, unless you personally live close to where the brokerage servers are located.
With OCO, if it's Native OCO then it would not be OCO causing in-flight-executions as this would be handled on the brokerage end. With local OCO, NinjaTrader sends cancellation requests and this can result in an in-flight-execution. Using Native OCO could prevent OCO from causing in-flight-executions. Ensuring the latency to the brokerage servers is as low as possible can help reduce the chances of an in-flight-execution with Local OCO.
With the message in your latest post, it looks like this was a manual close button pressed. An order was attempted to be manually cancelled but had already filled on the brokerage servers. This could indicate that the latency to the brokerage server is high, or just could have been a coincidence.
Leave a comment:
-
Also your links do not explain how to avoid the In-Fight execution.
Leave a comment:
-
Hi ChelseaB,
Yes,This Is.
I am connecting to OneUp Trader and I don't know they are using Native or Local OCO.
This is response of your support team
The first two orders highlighted in yellow were associated with a previous order, a stop that filled and the associated target that canceled:- 2020-09-24 03:27:47:424|1|32|Order='1147984655/AshkanOUP09161061' Name='Stop1' New state='Filled' Instrument='YM 12-20' Action='Sell' Limit price=0 Stop price=26614 Quantity=1 Type='Stop Market' Time in force=GTC Oco='c3179bb71c874ff18c5847b1f6178106' Filled=1 Fill price=26612 Error='No error' Native error=''
- 2020-09-24 03:27:47:424|1|32|Order='1147984656/AshkanOUP09161061' Name='Target1' New state='Cancelled' Instrument='YM 12-20' Action='Sell' Limit price=26643 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='c3179bb71c874ff18c5847b1f6178106' Filled=0 Fill price=0 Error='No error' Native error=''
This put you in a flat position:- 2020-09-24 03:27:47:311|1|64|Instrument='YM 12-20' Account='AshkanOUP09161061' Average price=26637 Quantity=1 Market position=Long Operation=Remove
Then, you entered short for four contracts with your attached strategy with a sell market order that filled at 26610.75 and 26611 (averaged out to 26611 for the entry price because there was a partial fill. This is the third highlighted entry from your screenshot:- 2020-09-24 03:27:47:823|1|32|Order='1147984735/AshkanOUP09161061' Name='Entry' New state='Partially filled' Instrument='YM 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=DAY Oco='' Filled=3 Fill price=26611 Error='No error' Native error=''
- 2020-09-24 03:27:47:948|1|32|Order='1147984735/AshkanOUP09161061' Name='Entry' New state='Filled' Instrument='YM 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=4 Type='Market' Time in force=DAY Oco='' Filled=4 Fill price=26610.75 Error='No error' Native error=''
Your associated target filled:- 2020-09-24 03:28:19:414|1|32|Order='1147984737/AshkanOUP09161061' Name='Target1' New state='Filled' Instrument='YM 12-20' Action='Buy to cover' Limit price=26603 Stop price=0 Quantity=4 Type='Limit' Time in force=GTC Oco='ab2c3ef20a29418c8184dea63b550b30' Filled=4 Fill price=26603 Error='No error' Native error=''
But then before you got a position update, you pressed 'Close':- 2020-09-24 03:36:33:570|1|4|Chart Trader close position
Since you had not yet received a position update, the platform saw that you had an open position for one of those contracts and submitted a market order in the opposite direction:- 2020-09-24 03:36:33:977|1|32|Order='1147985412/AshkanOUP09161061' Name='Close' New state='Filled' Instrument='YM 12-20' Action='Buy to cover' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=1 Fill price=26607 Error='No error' Native error=''
This is the fourth highlighted order in your screenshot, the close order.
Leave a comment:
-
Workaround for In-Fight execution
Hi
I am developing strategy and using ATM to take position( AtmStrategyCreate) also AtmStrategyClose to close order.
Despite the fact, would you please advice me how to avoid the In-Flight Executions or detect open order because of the in-fight and closed it.
Due to this problem my account is no longer eligible for funding and I need to find solid solution for it.
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by hazylizard, Today, 08:38 AM
|
0 responses
3 views
0 likes
|
Last Post
by hazylizard
Today, 08:38 AM
|
||
Started by Max238, Today, 01:28 AM
|
5 responses
42 views
0 likes
|
Last Post
by Max238
Today, 08:30 AM
|
||
Started by giulyko00, Yesterday, 12:03 PM
|
3 responses
12 views
0 likes
|
Last Post Today, 08:26 AM | ||
Started by habeebft, Today, 07:27 AM
|
1 response
14 views
0 likes
|
Last Post Today, 08:08 AM | ||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:57 AM |
Leave a comment: