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)
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
My first thought would be to simply do your logic in the OnOrderUpdate. That would be, in my opinion, the best bulletproof way to catch any inner monkey order and cancel it immediately. You could then either log a message in the control center or even pop up a dialog to let you know you made an erroneous move.
Gotchas: This would require you to use a strategy and would work only on the chart you applied it to but I think it'd be foolproof.
You'd be able to check logic against any indicator value without intervention. It would definitely take some work to get it right but you'd only have to do it once then you'd have your desired protection.
Yes I was looking at OnOrderUpdate for that reason, but still couldn't work out how to then cancel the incoming order. Do you have a code snippet that shows this?
I was thinking (sudo code):
I trade from Australia, so trading the S&P500 is 11:30pm to 2:00am here, which as has the expected bad side effects you can imagine. It's really about putting a safety net in place to counteract being tired etc. and making mistakes thereof. So I view this as a safety feature rather than a restriction and am confident just implementing this as a strategy would do the job.
Thanks Asterik, this is something that I would be keen todo, just to avoid the habitual mis-click on the standard buttons. Do you have a way on how this could be achieved. Doesn't need to be pretty, could be hiding the buttons or putting another GUI element in front of the buttons or similar.
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
That is almost exactly what I had in mind. Make sure to look at the NT8 documentation about order states because there are some gotchas in there from what I remember. I don't memorize them but always remember to check when I'm doing something based on order states. I never store my order object until I'm in that override versus when you do your buy or sell. It's possible the buy or sell method return order object won't be as populated as the order parameter you get from the override method.
Any resting order where you go from historical to realtime, you need to convert that order to a realtime order in the OnStateChanged state transition. You'll get an error in the control center (or maybe a pop-up). It has to do with how NT8 tracks orders internally.
You will probably need a local bool flag like isCancelInProgress that you first check for and then set to true so you don't end up in a loop as well as you let legitimate orders through. Also, I would store the order object from that override and check in OnExecution against any executed order just in case. That way you could immediately close it and only be out the spread plus maybe a tick.