Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Converting Limit to Market
Collapse
X
-
Converting Limit to Market
I've written code using a custom timer object to convert limit orders to market orders if not filled within 'x' seconds of being hit. However when I'm trying to test this code running NinjaTrader's simulator, the order is filled immediately upon the price being hit, so none of my code is executing. Is there a way to debug this aside from going live?Tags: None
-
I'm testing this and my order is getting double filled. It seems that the limit order fills once the price is hit, then the timer submits another order causing a second fill. Here is the code I'm using:
Then I have a timer object which calls this method.Code:protected override void OnBarUpdate() { //Send Order: LE = EnterLongLimit(amt,price,"LE"); //Track if Price has been touched: if (LE!=null && Low[0]<=LE.LimitPrice) pricetouched=ToTime(DateTime.Now); }
I also reset pricetouched to 0 in the OnExecution() method.Code:private void MyCustomHandler(object state) { if (LE!=null && LE.OrderState==OrderState.Working && pricetouched!=0 && ToTime(DateTime.Now)-convertseconds>pricetouched) { LE=EnterLongLimit(amt,Close[0]+4*TickSize,"LE"); } }
Comment
-
toptrader,
Not sure I follow. If your limit price is touched and you get part filled on the limit order this is expected no? You want to go ahead and check for such a PartFilled order state if you don't want to submit market order any more after a part fill.Josh P.NinjaTrader Customer Service
Comment
-
Well whether I am part filled or not, I want to amend the limit order 'x' number of seconds after the price is hit. I thought sending an order with the same order name would simply amend the working order, but it appears to be submitting a completely separate order. I read in another thread that it is faster to amend the order as opposed to cancel and submit a market order, however from what I've seen and your comments below it seems like I should check for a partial fill, cancel the current order and submit a new order for the balance. Does this sound correct?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment