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)
Looking for some pointers or a code snippet that would allow me to intercept (and cancel!) a users order submission. So to be precise: I'd like to:
a) intercepts the button clicks on the chart trader (buy market, sell market etc.)
b) evaluate certain conditions and
c) based on the result cancel the submission of the order under certain circumstances
From the NT forum I found the relevant script that let's me trigger additional activities off the back of the button clicks, so effectively a) and b) are sorted. My problem is that I am unable to cancel the order once it is submitted.
My thinking is:
- OnClick Event => Evaluate Condition => Cancel event submission (i.e. order)
...alternatively maybe implement this as a strategy and work with onOrderUpdate() and check for orderState.Initialised and then update the orderState to Cancelled.
Preferred would be to have this as a generic addon which just runs in the background rather than an indicator or strategy, but at this stage - any will do
Another option would be to implement new buttons which do the checks first and then submit the orders only when conditions are met.
Thanks in advance!
Frank
Can you help answer these questions from other members on NexusFi?
I don't have an answer, or any idea really, but this seems like an attempt to impose a last-ditch trade discipline on the trader.... which I can understand, knowing I sometimes ask myself afterward, "Why did I do that???"
Is this the intention? Just asking.
Or is it simply a last-minute check that the trader accurately took everything, or certain critical things, into account?
I could see value in both.
I hope someone responds with some actual coding help.
Bob.
When one door closes, another opens.
-- Cervantes, Don Quixote
I've tried using discipline aids like in Sierra using the "halt trading after some loss is met", and multiple times I have disabled them after they triggered.
So you need discipline to not disable the aid.
But then if you're disciplined you don't need the aid :-)
Spot on - it is intended as an approach to define a few market conditions under which I am happy to trade. e.g. something simple like "Only allow trades in direction of the 15min moving avg." and intercept attempts to do otherwise. The intend is to keep the "inner monkey" (refer FT71) in check which just clicks too much, too large and without consideration of context parameters. I anticipate it to be easy to disable, but I think it would still help me personally to just avoid dumb and expensive trades that severely damage my account.
You can register additional functions to the original buttons but you can't intercept their trade execution. Therefore you need to place your order through additional buttons that you can inject in the charttrader via an indicator. There you can implement all you checks before executing the order.
When you place an simple order or an ATMStrategy with your new buttons the existing cancel button is still working for them.
You already found the main thread in the NT forum for this topic.
If this is the case, can a new function be to close the newly opened position (or cancel the newly placed order)?
I ask because the OP stated they have a discipline issue, so ... Why would such a person click the button that might block what they want to do; instead of clicking the button that will certainly execute what they want to do?
The goal of self-forcing compliance, should be to make it as difficult as possible to timely circumvent the mechanism; otherwise, it won't work.
but finding a solution to hide the original charttrader entry-buttons seems to me a lot easier than implementing a solid order (and order state, ATM attached? OCO? ... ) detection function for an unknown entry order.
@Adfra I agree with @askerix that it may be easier to create custom buttons to do everything you want and hide the original buttons, instead of reprogramming the original order buttons.
I used the sample ChartTraderCustomButtonsExample code from the NT support thread you linked to create buttons tho submit a buy/sell stop limit orders at the high/low of the current & previous bar. The code can be modified to submit a different order type and add additional if conditions for your own rules. Here are the relevant parts to add within ChartTraderCustomButtonsExample
It will use the account, quantity, and instrument already selected in chart trader. I didn't do the ATM strat, so you just need to change the hard coded name from "1" to whatever the name of your ATM strat is. If you make improvements, please let me know if you figure out how to auto select the ATM strat already selected in chart trader instead of having it hard coded like I have it.
@planetkill
here is a solution to place the order with an ATMStrategy attached:
I use a similar setup to place stop limit orders above developing Range bars.
created entry orders (with attached ATM Strategy) can be adjusted with this code when the Order object is stored in the indicator:
In my case I am using buy/sell stop limit orders, so after the code submits the order, the order will sit until it is executed or canceled.
I'm guessing I'll need to check if the order was executed and if there is an active stop, OnOrderUpdate.