Rejected Order: "stop price must be below last trade price"  [SOLVED]

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Rejected Order: "stop price must be below last trade price"

Postby wilkinsw » 22 May 2013

Hi,

I have auto trading running and have encountered a rejected order (I use Patsystems, trade Euro FX on the CME):

"sell order stop price must be below last trade price".

This occurred when a stop was placed at entryprice on the open of next bar and price happened to be below entryprice on the open of next bar. When backtesting such an order would trigger an at market sell as price is below the stop trigger.

Is there a simple workaround or a setting I need to change somewhere.

This has many potential serious ramifications. I use stop entries. If price happens to close at 1.2922 on a 60min candle to generate a 1.2923 buy stop on the next bar BUT on the open of the next candle price skips through 1.2923 to 1.2925 then my order will be rejected.

What should I do?!

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Rejected Order: "stop price must be below last trade pri

Postby Andrew MultiCharts » 22 May 2013

Hello Wilkinsw,

This is your broker limitation, not the software limitation. What is the broker?

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Rejected Order: "stop price must be below last trade pri

Postby furytrader » 22 May 2013

I wouldn't put your stop so close to the prior bar's close to begin with. It almost negates the point of the stop - you're basically going to trade at the offer.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri  [SOLVED]

Postby wilkinsw » 23 May 2013

Thanks for the replies.

I've coded a suitable workaround for reference by other Patsystems users that run into the same issue.

By using "open next bar" you can turn a stop into a limit if your stop order is being rejected as its above (if exiting long) last traded price.

@furytrader. My stop (variable "lstop") is derived from doing a "maxlist" (if long) of lowest lows, a fixed stop and breakeven rules. In the case where lstop is shifted to breakeven as the high of the candle>=the breakeven trigger level, the open of the next candle can sometimes be below entryprice therefore generating the error.

Fix for entry stops:

if open next bar<(buystoplevel) then begin
buy ("masterl") nocontracts shares next bar at (buystoplevel) stop (buystoplevel+maxslippage) limit;
sell from entry ("masterl") next bar at ((buystoplevel)-stopf) stop;
end else if open next bar>=(buystoplevel) then begin
buy ("masterlb") nocontracts shares next bar at (buystoplevel+maxslippage) limit;
sell from entry ("masterlb") next bar at ((buystoplevel)-stopf) stop;
end;

Fix for exit stops:

if open next bar>lstop then begin
sell from entry ("masterl") next bar at lstop stop;
sell from entry ("masterlb") next bar at lstop stop;
end else if open next bar<=lstop then begin
sell from entry ("masterl") next bar at (close-(1000/pricescale)) limit;
sell from entry ("masterlb") next bar at (close-(1000/pricescale)) limit;
end;

TomTailor
Posts: 3
Joined: 22 Jan 2015
Has thanked: 1 time

Re: Rejected Order: "stop price must be below last trade pri

Postby TomTailor » 22 Jan 2015

Hello Wilkinsw,

This is your broker limitation, not the software limitation. What is the broker?
And which broker not have this limitation? A have now a AMP futures and there i have same problem. Interactive broker is good? (sory for my english)

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

This takes me back!

Most (if not all) exchanges will reject a stop order if (in the case of a buy stop) the last traded price is above the stop price.

Therefore you need to insert logic that checks if the "open next bar" is above the intended stop price. If it is then submit a limit order at price=intended stop price, else submit the original stop order.

Let me know if you don't understand.

Code: Select all

Fix for entry stops:

if open next bar<(buystoplevel) then begin
buy ("masterl") nocontracts shares next bar at (buystoplevel) stop (buystoplevel+maxslippage) limit;
sell from entry ("masterl") next bar at ((buystoplevel)-stopf) stop;
end else if open next bar>=(buystoplevel) then begin
buy ("masterlb") nocontracts shares next bar at (buystoplevel+maxslippage) limit;
sell from entry ("masterlb") next bar at ((buystoplevel)-stopf) stop;
end;

Fix for exit stops:

if open next bar>lstop then begin
sell from entry ("masterl") next bar at lstop stop;
sell from entry ("masterlb") next bar at lstop stop;
end else if open next bar<=lstop then begin
sell from entry ("masterl") next bar at (close-((100prices/pricescale)*minmove)) limit;
sell from entry ("masterlb") next bar at (close-((100prices/pricescale)*minmove)) limit;
end;
Last edited by wilkinsw on 22 Jan 2015, edited 1 time in total.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Rejected Order: "stop price must be below last trade pri

Postby Andrew MultiCharts » 22 Jan 2015

And which broker not have this limitation? A have now a AMP futures and there i have same problem. Interactive broker is good? (sory for my english)
As far as i know IB doesn't have such limitations. Please contact the supported brokers directly to find out: https://www.multicharts.com/brokers/

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

Andrew,

It should be exhange dependant, not broker.

If your futures broker is telling you they accept a stop order that would otherwise be rejected by the CME, for example, then I'd advise to change broker. Reason being it would sound like the broker could be at worse "bucketing" your order or, less worse, is introducing latency by accepting, what should be an exchange native order as a synthetic one.

TomTailor
Posts: 3
Joined: 22 Jan 2015
Has thanked: 1 time

Re: Rejected Order: "stop price must be below last trade pri

Postby TomTailor » 22 Jan 2015

wilkinsw i send you email with my code. I dont understand bud i need how you fix on my code (i am also beginer in programing) Thank you very much!!!!

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

I'm afraid i'm not prepared to get involved directly in what sounds like code that going straight into production.

the solution is above , i advise you understand it before implementing it.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

This topic is -so- timely. I found it just as I was about to open a new topic myself on the same subject!

For everyone's info, I report/confirm that AMP will reject a stop entry order if the market has ticked beyond the stop entry price at the moment the order is received.

I spoke with the AMP Help Desk and the rep confirmed that it is the AMP order servers (not the Exchange) which are doing the rejection. Now, to be sure, this rep did not personally do the programming of that, so I don't have 100% confidence in what he said, but he seemed sure enough about it, so I'll call it 95% confidence <g>.

--

THIS IS UNLIKE INTERACTIVE BROKERS.

IB will fill such orders. This personally long-observed fact tends to support that the stop-entry order rejections under discussion are broker-created and not Exchange-created.

In my case, the exact same automated strategy generating the exact same orders gets fills from IB and rejections from AMP (in those cases where there was not enough padding to prevent the market price from ticking past the stop entry price before the order was received).

So, strategy will have to be adjusted and/or programming will have to be more sophisticated for the AMP case and for other similar brokers.

Sigh. (But that's life in the real world!)

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

Hi wilkinsw.

Thank you for your comments and suggestions here.

Can you say if your real-world experience with the code you posted above has shown that maxslippage has to be a certain minimum number of ticks in order to prevent still having some orders come back rejected?

TomTailor
Posts: 3
Joined: 22 Jan 2015
Has thanked: 1 time

Re: Rejected Order: "stop price must be below last trade pri

Postby TomTailor » 22 Jan 2015

MC_prog so only basic english. You tell AMP have problem with stop order? Yes or no?

And Interactive Brokers is OK for stop orders (for automated strategi). Yes or no?

Thank you and sory again for my english!!

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

Hi MC_Prog,

I think you're a little confused in places. Please let me help.

1) It IS primarily and most importantly an exchange driven issue. Quote from CME:

"Stop order trigger price is validated versus the last trade at order entry. A Buy order must be > last trade price and a Sell order must be < last trade price."

http://www.cmegroup.com/confluence/disp ... nd+Options

Anything to do with the broker is very much secondary. If the broker is rejecting your order in this case, then it is because they don't want to send an order to market that will be rejected (if what your contact at AMP said is at all true, that is).

As I said before.... if IB can get an order filled that the exchange would otherwise reject then you are not sending an exchange native stop order at all. Instead you are sending a synthetic instruction to IB which they are then interpreting (whether to send as a stop or limit etc). I personally don't like the sound of that for the reasons I mentioned previously. If in doubt always opt for NATIVELY supported orders.

To answer your last question:

I don't think you've understood the code. Input "maxslippage" has nothing to do with avoiding order rejections. It's the "open next bar" that helps us:

Code: Select all

if open next bar<(buystoplevel) then begin
buy ("masterl") nocontracts shares next bar at (buystoplevel) stop (buystoplevel+maxslippage) limit;
This means, if our stop order will be accepted (as per the most recently received data update) then send as a stop. All natively supported stopmarket orders by the CME are technically "stoplimit" orders, the "limit" part being deep into market (how deep can be found on the CME website). I chose to define my worst price (the "limit" part) manually. Ie my worst price is stop trigger price + "maxslippage" ticks. So in the code I'm showing here, I'm trying to send a natively supported "stoplimit" order.

Code: Select all

end else if open next bar>=(buystoplevel) then begin
buy ("masterlb") nocontracts shares next bar at (buystoplevel+maxslippage) limit;
This means that if our stop will be be rejected (as per the most recently received data update) then send order as a limit. The limit price is the "worse price". Note you will get filled at the prevailing offer at the point your order hits the matching server. It is very hard to get a limit order rejected (it would have to be beyond price reasonability parameters set by the CME).

So to conclude the input "maxslippage" has nothing to do with the order rejections, which is what you've seemed to have confused it with.

If the above code is still giving you order rejections then it is likely that your latency is too high for the speed of the market and/or your desired style of trading.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

wilkins, you are right on all counts. Thanks for sharing that code. I have seen that "if open next bar ..." before but I have always stayed away from it but you make a good case for looking at that idiom again.

MC_prog have you verified that IB will accept a stop that will be rejected per the CME rules? If so, then they must be "internalizing" the order flow. I know they "internalize" in equities trading. Is that also allowed in futures trading?

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

MC_prog have you verified that IB will accept a stop that will be rejected per the CME rules? If so, then they must be "internalizing" the order flow. I know they "internalize" in equities trading. Is that also allowed in futures trading?
Awesome question!!

MC_Prog,

Found out the answer to this and I will always think of you as a legend!

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

I knew "internalizing" is the norm in equities. According to recorded statements of Thomas Peterffy in 2010 criticizing the practice, equities brokers internalize 95% of the order flow. Looking over some CME rules, this seems to be legal in futures too.

So key question: how much equities and futures order flow is internalized by IB?

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

wilkinsw,

I track everything you said. Great reference to the CME site, BTW.

However, one point I do wish to explain about my question -

Adding maxslippage (if non-zero) raises the maximum executable price, moving the maximum executable price further from the current market and thus making it more likely to avoid the market's having crossed that price (thus invalidating the order) during the latency of transmission.

The order matching server is not going to care what the close of the last bar was or the open of the current bar. It is only going to care what it is currently representing internally as the "last trade price".

IOW, transmission latency is non-zero and could be (is) relevant. Switching to using a market order based on the 'open next bar' may be a pretty good approximation to avoid cases where the stop entry order would obviously (and in hindsight) have been rejected, but it really is just delaying the entire process slightly (until 'open next bar' is available locally to be checked), and the result of this delayed process could STILL be a stop entry order transmitted with a maximum executable price which is seen to have been passed by the market as of the moment the order matching server checks. Result: rejection. I'll call this the "outlier case".

The greater the value of maxslippage, the less likely the outlier case can happen.

Is my logic here incorrect? If so why? (Sorry if I'm missing the obvious ...)

Later note: For some reason I was thinking that maxslippage was affecting the trigger price. I don't know why I was thinking that. So, yes, the above is incorrect, as is pointed out later in the thread by wilkinsw.
Last edited by MC_Prog on 24 Jan 2015, edited 2 times in total.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

MC_prog have you verified that IB will accept a stop that will be rejected per the CME rules? If so, then they must be "internalizing" the order flow.
I have no such verification as a policy/practice per any IB employee (so far anyway).

However, I have over 80 two-sided IB stop entry trades sent in recent times and never have I had an order rejected.

AMP immediately rejected some of the very same orders. Could this be pure luck/coincidence? In theory, yes. But it seems highly unlikely.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

A couple of errors:

1) Open next bar - I'm afraid code is executed and orders submitted on the first tick of the new bar. Therefore no additional latency is added by "waiting" for the opening price.

2) "Maxslippage" or "worse price" is completely different to "trigger price". It is the trigger price that matters with regards to having a stop order accepted/rejected. If the stop order is accepted, then job done. IF traded price = trigger price of an accepted and working stop/stoplimit order THEN the native order converts into a limit order, the price of which is defined by the "worst price" portion here. In this case this is trigger+"maxslippage". If using a "stopmarket" then the CME will convert a triggered stop order into a limit order with worse price at trigger+"pre-defined protection point range". In BOTH cases once triggered the limit order will NOT be rejected (as long is less then the pre-defined protection point range). THEREFORE "Maxslippage" has absolutely no effect on the rate/likelihood of a stop order being rejected! If you set "maxslippage" to a value greater than the pre-defined protection point range then your stoplimit order will be rejected. But you would have no reason to do this. If you are sending the order as just a limit: Again, you're getting filled or you are joining the book or you are getting rejected if your limit price is beyond last price + pre-defined protection point range. Simple stuff.
Last edited by wilkinsw on 22 Jan 2015, edited 1 time in total.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

MC_Prog,
I have no such verification as a policy/practice per any IB employee (so far anyway).
Let's avoid conjecture. Just ask them. Quote the CME rules on stop orders and then ask them if they practice the same rule.

If the answer is no: Then ask how they are handling your orders to circumvent the CME rules. Ask them if your stop orders are being sent straight through or not. If not, why. Etc etc.

This is pretty important stuff tbh. I would've thought even part timers would want to know this!


wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

MC_Prog = legend!

I personally find that terrifying. I've only briefly looked at the link you sent, but my next question is does IB offer direct market access and the straight through handling of natively supported orders at all? Maybe as a selectable option?

I find it terrifying because it's this type of practice which opens up the potential for customer order flow to be sold on to predatory HFT firms.

I'm actually shocked!

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

For trading CME futures with IB, stop orders are simulated while stop-limit orders are native per IB website. That explains the difference between AMP and IB treatment of your stop orders.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

I just got off the phone with IB - conference call with one rep from the trade desk and one from the API group.

Here's the deal in a nutshell -

Submitted Stop Orders: are held by IB servers, triggered by price action, and sent to the exchange as "marketable limit orders" (i.e. limit orders ready-to-be-filled by virtue of having in-the-money limit prices, some # of ticks away from the current market).

Submitted Stop Limit Orders: are sent right thru to rest on the Exchange. If they don't pass muster at the Exchange, then they will be rejected (of course).

In general, there are 3 potential levels of rejection: locally in TWS, at the IB Server, at the Exchange. The origin of the rejection is not stamped on the rejection message, but if you really need to know in a specific case, you can call IB and they can tell you based on the message where the rejection came from.

For even more detail, drill into these links (and children):

https://www.interactivebrokers.com/en/? ... 2Fstop.php
https://www.interactivebrokers.com/en/? ... pOrder.php
Last edited by MC_Prog on 22 Jan 2015, edited 2 times in total.

User avatar
MC_Prog
Posts: 330
Joined: 28 Feb 2007
Has thanked: 64 times
Been thanked: 35 times

Re: Rejected Order: "stop price must be below last trade pri

Postby MC_Prog » 22 Jan 2015

My AMP stop orders were rejected because they were simply passed to the Exchange and rejected based on the stop trigger level not being outside the current price.

My IB stop orders were filled because the IB Server saw that my stop trigger level had been exceeded and so converted the stop orders (-not- stop limit orders) into marketable limit orders which then immediately filled.

That's it. Now to figure out all the implications and what I really want do with my strategy code <g>.

Cheers!

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

Here's the deal in a nutshell
Submitted Limit Orders:
Submitted Stop Limit Orders:
IB claims both of these as 'native' on its website. So your findings are in line with what they say on the web. OTOH, their website says stop and market orders are 'simulated'. Did you ask them about stop orders too? Is 'simulated' a euphemism for 'internalized' or do all stop orders get routed to CME?

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

Please anyone contest me , but:

IB smells very bucket shop like:
IB may simulate stop orders with the following default triggers:

Sell Simulated Stop Orders become market orders when the last traded price is less than or equal to the stop price.
Buy Simulated Stop Orders become market orders when the last traded price is greater than or equal to the stop price.
That is free money for IB. If I'm IB or an HFT customer/subscriber of IB's flow, I can uptick these prices and I know exactly what volume of orders will follow me. This opens up front running basically.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

wilkins, after looking into their fine print, I am inclined to agree with you that at least for stop and market orders, which are 'simulated' per their web page, the dice is loaded against IB customers.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby wilkinsw » 22 Jan 2015

I think we've demonstrated the importance of researching:

1) The exchange. Always the most important as this should ultimately represent the playing field.

2) Your broker and how they handle your orders and communicate with respective exchanges.

Reading the IB website, if using stoplimit orders you should be getting direct market access. "Stopmarket" orders are synthetically managed by IB.

To conclude. If using IB the optimal solution would be to:

1) if open next bar is at all close to you stop trigger price, then submit as an IB synthetic stop market order.

2) In all other circumstances submit your stop(market) orders as stoplimit orders but with the limit minus stop gap sufficiently large as to ensure the fill.

This should give you the best of both worlds. In other words, protect you from both rejections and corruption.

orion
Posts: 250
Joined: 01 Oct 2014
Has thanked: 65 times
Been thanked: 104 times

Re: Rejected Order: "stop price must be below last trade pri

Postby orion » 22 Jan 2015

Good advice. Also, rejection and corruption can sometimes be one and the same; rejection can be a result of corruption and corruption itself comes in two possible forms: price (slippage) and time (latency).


Return to “MultiCharts”