Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I normally use market orders and would like to try limit orders and have a few questions.
1. How do you cancel a limit order after a certain amount of time if it has not been executed (I see there is an option to convert to a market order after a set …
The initial response in this post was: “All orders are canceled and replaced at the start of each new bar. To cancel it in effect, just don't reissue the Buy or Sell order.”.
I don’t understand this answer. If I have a strategy order to “buy at XX on a limit”; and xx is hit, but the order is not filed; then certainly the order will sit there, waiting to be filled until:
a) it is filled, or
b) it is cancelled.
So; can anyone tell me how to code (in TS EL) a command to “Cancel a limit order after XX minutes, if my price has been hit, but the order has not been filled.” ?
Thank you in advance for your consideration.
Can you help answer these questions from other members on NexusFi?
an order will remain "alive" as long as the condition you use to issue the order is valid. You can use this to your benefit by making the condition invalid after X minutes for example.
In your case you will likely require intrabar order generation and you need to detect if the price hit your limit price within your code.
Hello ABCTG,
Thanks (as always) for your prompt reply. You are a 'Beacon of Light' to all of us amateurs.
I'm using Kase charts in my trading, so Intrabar Order Generation is not allowed.
TradeStation offers a (non-EasyLanguage) option to convert an unfilled Limit Order to a Market Order after xx seconds. It seems like we should be able to code something similar for cancelling the unfilled Limit Order after xx seconds. No??
you are welcome. What I wrote is still valid, with or without intrabar order generation. However without IOG you can only reset the conditions at the end of the bar and thus cancel your order at that point (which will likely not match X minutes after the order was triggered).
You might be able to walk around this with OOEL, but you couldn't backtest your code then.
based on my above statement "an order will remain "alive" as long as the condition you use to issue the order is valid", the order would be cancelled by TS as soon as Condition1 (in your case) is not "true" anymore.
You would have to debug your code (using print statements for example) to check if setting MP = 1 at the location where you do it actually means you are filled, as from the code snippet I wouldn't necessarily expect that.
Thanks for your prompt reply. I don't know how (or why) you find the time to babysit guys like me.
OK - so per your response; I'll determine my Market Position (MP = 0 versus MP = 1) before and after my Limit Order has been triggered, but not filled.
Along with this, I'll determine my 'Condition 1' status on the 'Trigger bar' and subsequent bars.
Using these two data-points, I'll see if I can noodle-out a way to auto-cancel the order.
As always, thanks for your feedback. I learn something new about EasyLanguage from each of your posts.
you are welcome. Based on your code snippet you set MP = 1 when your Condition1 is fulfilled. Now it depends on what you mean with "your limit order got triggered" - as it could be the act of TS sending the limit order to the exchange/execution network or price touching/crossing your limit price. If you are looking for the sending of the order the code is fine, but if it's the latter you'd need to monitor if price touched/crossed your limit price.
I am posting here, since it is the closest post I found regarding what I want to do.
My strategy will enter long with a limit order -1 tick of the actual price when the conditions of the strategy are met. One of the condition is the crossover of the MACD, so that condition will not remain satisfied on the next bar update, so the limit order get cancelled on bar update (my order is only valid for 5 minutes..., the time of one bar).
I would like to keep the order good till 'x' amount of bar updates. Seems to be a simple concept, but I didn't find anyone doing it on ninjatrader, neither on other Platform.
I thanks in advance anyone who can help on that. Be aware that I am using NinjaTrader8 and I am not a coder...