Welcome to NexusFi: the best trading community on the planet, with over 200,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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
So here's the issue I'm having, If you place two orders through strategy automation, one a sell above the current bar and one a buy below the current bar, Tradestation on their end will hold both but only place the order you are closer to. If the price action starts to become very fast an error can occur where Tradestation attempts to cancel an order before it is sent. Now, this issue is on Tradestations side not in the code which I know for certain from troubleshooting with Tradestation Easylanguage support. What I'm trying to do as a work around and not having any luck with yet is in 'using elsystem' to listen for a rejection and then recalculate(restart) the strategy so it continues in automation. Of that attempted solution my only problem is I have been unable to find any way to listen for a rejected order. Mind you, I'm not actually placing the order again, it's only calculated end of bar, Tradestation is holding both orders and placing one or the other based on proximity so I need to not listen for a rejection on an order I'm placing but just any rejection at all on the account. Thanks for the help! And let me know if my explanation isn't cutting I'm still finding it a little confusing myself!
Can you help answer these questions from other members on NexusFi?
KPreston,
have you checked the OCOOrderTicket object, this should allow what you have in mind with automated cancellation of the opposite order? Alternatively you might want to look at the Orders Class. This should allow you to monitor for changes of particular order.
Unfortunately that's not really what I'm looking to do. The rejection is after both orders have been placed; Tradestation platform then automatically will take away and place orders as you gain proximity to them, in rapid succession you end up with a rejection. What I really would love to do is watch for a rejection, flatten, and recalculate the strategy. Normally when an automated strategy gets a rejection it turns itself off which in rare circumstances can leave you in a trade. Now, I would always recommend not running a live strategy with you not present but that does not mean that all people do so my goal is rather than automation shutting off just recalculate and proceed or at least flatten the position if it is going to shut off! Any Ideas?
This is a real problem with bracket order management in fast markets -- TradeStation yanking and replacing orders in rapid succession until one gets rejected and kills your automation. Leaving you stuck in a position with no strategy running is the worst-case scenario.
The good news: EasyLanguage has the tools to handle this. Here's the approach:
1. Monitor order state via the OrdersProvider
The tsdata.trading namespace gives you access to an OrdersProvider component that tracks all account orders in real time. You can monitor order state changes and check for a Rejected status on each update. That's your trigger.
2. Flatten on rejection
When you detect a rejected order, issue a market order to flatten before doing anything else. Don't try to be clever here -- just get flat. A rejected order means something went wrong with the order flow, and you don't want to sit in a position while your strategy figures itself out.
3. Force recalculation with RecalculateException
This is the key piece. After flattening, use:
This forces the strategy to recalculate from scratch rather than shutting down. Markplex Tutorial 116 covers the RecalculateException pattern in detail -- worth reading through.
4. Automation settings to check
In your strategy properties, look at two settings:
WaitForUROutConfirm -- prevents sending new entries before the previous cancellation confirms. This alone can reduce rejection cascades.
"Strategy will fill non-historical orders only when the TradeManager reports" -- keeps your strategy state synced with actual fills.
One more thing -- if you're trading oil (CL), keep in mind that CME has limit order band restrictions that reject orders placed too far from the current market. That's a separate rejection type from the platform-level issue you're describing, but it can compound the problem during volatile moves. Pre-validating your order prices against the current market before submission can help catch those.
The RecalculateException approach is probably the cleanest path to what you want -- detect, flatten, restart. No shutdown required.
-- Fi "The best automation isn't the kind that never breaks -- it's the kind that knows how to pick itself back up."
Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.
Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.