Thank you!
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
Fill or kill order add-on
Collapse
X
-
To be more precise: a stop limit order that if it is not filled at the desired price with 1 contract, for the first time the price action passes through that value, then it is automatically canceled.
So the condition would be not to be filled in the same bar, but at the first brake of the desired price, because on a bigger time-frame setup or a renko setup, that would leave the possibility of the order to be filled the second or the third time the price hits the desired value.
Thanks!
Comment
-
Hello Sgr888,
It sounds like you are trying to create an automated NinjaScript Strategy, is this what you are creating?
I am also not fully understanding "if it is not filled at the desired price with 1 contract, for the first time the price action passes through that value".
Are you wanting to send a cancellation if the price touches the order and the order does not fill?
(As a heads up, this is likely to result in an in-flight-execution and trigger an overfill if the order begins to fill as the cancellation is sent)Chelsea B.NinjaTrader Customer Service
Comment
-
Yes, I want to integrate this type of order in an automated NinjaScript Strategy.
Well then if the order is canceled after the bar is closed does the possibility of in-flight-execution diminishes?
Yes, as seen in the 1 tick chart attached, I need the order to be filled in point A only, if not to be canceled. Getting filled in point B is not what I need.
Thanks!
Comment
-
Hello Sgr888,
I have moved your thread from the NinjaTrader 8 Addon Development section to the NT8 Strategy Development section of the forums.
If the order has not filled the entire time the bar was open, likely the current price is not near the order, the order is not as likely going to fill and not as likely to trigger an overfill.
If the current price touches the order and immediately a cancellation is sent, likely the current price is very near the order, the order is much more likely to experience a fill, and is much more likely to experience an overfill with the cancellation.
You can do this though.
You will need intra-bar granularity either from a secondary tick series or from Calculate set to .OnEachTick / .OnPriceChange. In OnBarUpdate you would compare the limit or stop price of the order to the current price. If they are equal then check the order state and and send a cancellation.
To cancel an order use CancelOrder().
For example:
Code:private Order myOrder; protected override void OnBarUpdate() { if (Position.MarketPosition == MarketPosition.Flat) { myOrder = EnterLongStopLimit(High[0] + 5 * TickSize, High[0] + 5 * TickSize); } if (myOrder != null && (myOrder.OrderState == OrderState.Accepted || myOrder.OrderState == OrderState.Working) && myOrder.StopPrice == Close[0]) { CancelOrder(myOrder); } }
Last edited by NinjaTrader_ChelseaB; 05-09-2017, 10:13 AM.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello Sgr888,
EnterLongStopLimit places a stop limit order.
EnterLong places a market order which will fill immediately.
I've set the buy stop limit stop price to 5 ticks above the high of the trigger bar. High[0] is the high of the bar. 5 * TickSize adds 5 ticks to that price.
A buy stop limit must be placed above the ask price.
No, I am not recommending that you replace your code with the sample code I have posted. I am recommending that you use this concept where you need in your own script.Last edited by NinjaTrader_ChelseaB; 05-10-2017, 07:01 AM.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by brunoviveiros, 02-17-2020, 05:31 AM
|
4 responses
63 views
0 likes
|
Last Post Today, 06:25 AM | ||
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
8 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
11 views
0 likes
|
Last Post Today, 02:34 AM |
Comment