NexusFi: Find Your Edge


Home Menu

 





Flash proof stop limit orders


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one Virtuose1 with 3 posts (1 thanks)
    2. looks_two iantg with 2 posts (6 thanks)
    3. looks_3 aquarian1 with 1 posts (2 thanks)
    4. looks_4 tpredictor with 1 posts (1 thanks)
      Best Posters
    1. looks_one iantg with 3 thanks per post
    2. looks_two aquarian1 with 2 thanks per post
    3. looks_3 tpredictor with 1 thanks per post
    4. looks_4 Virtuose1 with 0.3 thanks per post
    1. trending_up 1,623 views
    2. thumb_up 10 thanks given
    3. group 9 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Flash proof stop limit orders

  #1 (permalink)
 
Virtuose1's Avatar
 Virtuose1 
Montreal, Qc, Canada
 
Experience: Advanced
Platform: NinjaTrader 7
Broker: Interactive Brokers
Trading: ETF
Posts: 58 since Jun 2011
Thanks Given: 142
Thanks Received: 41

The following article does a great job at setting the context of my question: https://sixfigureinvesting.com/2012/10/needed-a-way-to-flash-proof-your-stop-limit-orders/

I'd be interested to get other traders insights on how best handle stop limit orders of automated algos during flash crash events.


Thanks

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #3 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148


Hi Virtuose1,

I will just start by saying that I use these a lot and with the high volatility we have seen lately, there have been lots of days that behaved like flash crashes almost. There are definitely pros and cons to using these though.

Pros: These are obvious. You can protect yourself from a large swing in the price against you. You can also capture the spread and use these to scratch trades at a break even, or only lose 1 to 2 ticks if you time your exits with your algo in such a way that you do not cross the spread.

Cons: Depending on when and where you place these, you can have scenarios where you miss your fill and the market moves against your position further and you are left naked. For example if you are trying use a passive exit on the Ask to get out of a long position, this can help you recover 1 tick, but it can also create a risk that you miss your fill and market continues down depending on how far out you place your order. If you are submitting this on the current price level or 1 price level out and the price level quickly moves, then you are exposed to this risk. If the current price level is at bid = 2000 and ask = 2000.25 and you place your stop limit at Sell Ask @ 2000.25, then the only way you are guaranteed a fill is if the Ask queue clears and everyone @ 2000.25 is filled and the price level moves up to Bid = 2000.25 and Ask = 2000.5. But conversely if the price level moves down to Bid = 1999.75 an Ask = 2000 then this implied that the bid queue was cleared and you may not have been far enough up in the ask queue at 2000.25 to get filled. So the market can continue downward without you leaving you naked and afraid (Metaphorically of course).

I typically only use stop-limits 3-5 ticks out from my entry to avoid the very situation i described in my "cons" section. But as long as my execution timing relative to the market speed is fast enough I avoid the scenario I described. To catch a scratch exit or maintain the spread on any other exit, I just use regular limit orders timed perfectly for the current price level to know which side to submit to (The bid or Ask). I usually give my self 3 5 levels to chase that sweet passive exit before I give up and just use the stop limit as my safety exit. Obvious this all has to be done using level 2 event handlers (more granular that a 1 tick chart for example) to optimize what you are reacting to. And unless you are collocating, and writing highly optimized speed efficient code this will not work for you either. For example with Ninja trader if you wait until OnPositionUpdate occurs to react to something you will be too late most of the time.

I also have another layer of code after the stop limit if I hit the "con" scenario I described to cross the spread and get out with a market order. This is only triggered as a last resort though.

I think the use case I have described is fairly common for any serious robust algo trader.

Best of luck out there!

Ian

In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 
Virtuose1's Avatar
 Virtuose1 
Montreal, Qc, Canada
 
Experience: Advanced
Platform: NinjaTrader 7
Broker: Interactive Brokers
Trading: ETF
Posts: 58 since Jun 2011
Thanks Given: 142
Thanks Received: 41


iantg View Post
Hi Virtuose1,

I will just start by saying that I use these a lot and with the high volatility we have seen lately, there have been lots of days that behaved like flash crashes almost. There are definitely pros and cons to using these though.

Pros: These are obvious. You can protect yourself from a large swing in the price against you. You can also capture the spread and use these to scratch trades at a break even, or only lose 1 to 2 ticks if you time your exits with your algo in such a way that you do not cross the spread.

Cons: Depending on when and where you place these, you can have scenarios where you miss your fill and the market moves against your position further and you are left naked. For example if you are trying use a passive exit on the Ask to get out of a long position, this can help you recover 1 tick, but it can also create a risk that you miss your fill and market continues down depending on how far out you place your order. If you are submitting this on the current price level or 1 price level out and the price level quickly moves, then you are exposed to this risk. If the current price level is at bid = 2000 and ask = 2000.25 and you place your stop limit at Sell Ask @ 2000.25, then the only way you are guaranteed a fill is if the Ask queue clears and everyone @ 2000.25 is filled and the price level moves up to Bid = 2000.25 and Ask = 2000.5. But conversely if the price level moves down to Bid = 1999.75 an Ask = 2000 then this implied that the bid queue was cleared and you may not have been far enough up in the ask queue at 2000.25 to get filled. So the market can continue downward without you leaving you naked and afraid (Metaphorically of course).

I typically only use stop-limits 3-5 ticks out from my entry to avoid the very situation i described in my "cons" section. But as long as my execution timing relative to the market speed is fast enough I avoid the scenario I described. To catch a scratch exit or maintain the spread on any other exit, I just use regular limit orders timed perfectly for the current price level to know which side to submit to (The bid or Ask). I usually give my self 3 5 levels to chase that sweet passive exit before I give up and just use the stop limit as my safety exit. Obvious this all has to be done using level 2 event handlers (more granular that a 1 tick chart for example) to optimize what you are reacting to. And unless you are collocating, and writing highly optimized speed efficient code this will not work for you either. For example with Ninja trader if you wait until OnPositionUpdate occurs to react to something you will be too late most of the time.

I also have another layer of code after the stop limit if I hit the "con" scenario I described to cross the spread and get out with a market order. This is only triggered as a last resort though.

I think the use case I have described is fairly common for any serious robust algo trader.

Best of luck out there!

Ian

Thanks a lot for taking the time to provide your answer Ian, truly appreciated.

The stop-limit orders that I use are custom developed in NT. The sell order is triggered once the max daily loss % is reached and the price of the limit order is adjusted real-time (i.e.: will move with the market to increase chances of being filled). To avoid the scenario where the market would fall very quickly and my sell limit order wouldn't get filled, I thinking of something like:
- Price drop within "standard threshold" (whether ATR or % based): use my regular stop loss limit order
- Price drop is "acute" : set my limit price quite a few ticks below the bid to increase chances of being filled
- Price drop is "insane" (e.g.: flashcrash with price dropping over 50%): Do nothing and wait to be back in "acute" level

Other traders thoughts are welcomed.

Thanks again

Started this thread Reply With Quote
  #5 (permalink)
 iantg 
charlotte nc
 
Experience: Advanced
Platform: My Own System
Broker: Optimus
Trading: Emini (ES, YM, NQ, ect.)
Posts: 408 since Jan 2015
Thanks Given: 90
Thanks Received: 1,148

HI Virtuose1,

Since some of your use case relates to speed of execution and you are on NT, I think I can help you out with a couple more thing to consider.... (You may already know some of this but I am just going to punt it out there in case you find it useful.) I would have killed to have known some of this early on when I was pulling out my hair...

One thing you may want to research with the approach you mentioned is: What is the performance difference executing change orders vs. submitting new orders as the market moves. If you are using NinjaTraders managed approach, you may not see this nuance in the code, and may not realize the difference... but any sort of change order will typically take longer to process vs submitting a new order. How long may depend on your broker, data feed, proximity to the exchange and how you code.

In my case a change order can take 50 milliseconds to up to 200 milliseconds but a new order typically executes for me in < 10 milliseconds. I am using CGQ / NT Brokerage and co-locating in Chicago near the exchange on a VPS as a reference point.

Once I missed a few fills chasing the price with change orders, I started laddering different passive limit exits as new orders at different tick intervals. My execution speed has improved by a significant magnitude because of this.

But there is a big time downside with this... I am using the unmanaged approach and coding this type of complexity has been fairly time consuming to test and debug because you are ultimately left with several unfilled orphan orders and you will have to manage the cancels with custom logic. But if you are up for the challenge and don't mind the headache of going unmanaged and coding some complex order routing, your reward can be 100 to 200 millseconds better execution on every exit.


And one final thing, since you are a fellow NT coder out there fighting the good fight.... The most granular event hander you can use with NT is of course OnMarketDepth so one would think that it would be best to use this capture price level changes for example: marketDepthUpdate.Bid. But in actuality the OnBarUpdate events front run the OnMarketData and OnMarketDepth event by sometimes as much as 1 to 2 seconds. Typically this is around 100 millseconds, though sometimes they can be in sync. I have also learned that regardless of what event handler you use to call the OnBarUpdate event. GetCurrentBid() for example, the frequency of the update will always be based on your selected time series. So if you want to capture the price level changes as fast as NinjaTrader is capable of doing it. You have to go with the OnBarUpdate methods of GetCurrentBid() and GetCurrentAsk() and unfortunately you will have to run the time series of Tick and the value of 1 (This is as granular as it gets with NT). The OnBarUpdate method is far less granular that the level 2 method and typically only take an update 1 time for every 10,20, 50 updates you get with level 2 data, but when a price level ever changes this will always update first.

Also stay away from OnPositionUpdate events and always go with OnOrderUpdate because this will be significantly faster to capture your order state changes.


If you add all these little things up you are likely going to gain 1 full second and that makes all the difference in the world using limit orders chasing exits.


Best of luck!

Ian



Virtuose1 View Post
Thanks a lot for taking the time to provide your answer Ian, truly appreciated.

The stop-limit orders that I use are custom developed in NT. The sell order is triggered once the max daily loss % is reached and the price of the limit order is adjusted real-time (i.e.: will move with the market to increase chances of being filled). To avoid the scenario where the market would fall very quickly and my sell limit order wouldn't get filled, I thinking of something like:
- Price drop within "standard threshold" (whether ATR or % based): use my regular stop loss limit order
- Price drop is "acute" : set my limit price quite a few ticks below the bid to increase chances of being filled
- Price drop is "insane" (e.g.: flashcrash with price dropping over 50%): Do nothing and wait to be back in "acute" level

Other traders thoughts are welcomed.

Thanks again


In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 
Virtuose1's Avatar
 Virtuose1 
Montreal, Qc, Canada
 
Experience: Advanced
Platform: NinjaTrader 7
Broker: Interactive Brokers
Trading: ETF
Posts: 58 since Jun 2011
Thanks Given: 142
Thanks Received: 41


iantg View Post
HI Virtuose1,

Since some of your use case relates to speed of execution and you are on NT, I think I can help you out with a couple more thing to consider.... (You may already know some of this but I am just going to punt it out there in case you find it useful.) I would have killed to have known some of this early on when I was pulling out my hair...

One thing you may want to research with the approach you mentioned is: What is the performance difference executing change orders vs. submitting new orders as the market moves. If you are using NinjaTraders managed approach, you may not see this nuance in the code, and may not realize the difference... but any sort of change order will typically take longer to process vs submitting a new order. How long may depend on your broker, data feed, proximity to the exchange and how you code.

In my case a change order can take 50 milliseconds to up to 200 milliseconds but a new order typically executes for me in < 10 milliseconds. I am using CGQ / NT Brokerage and co-locating in Chicago near the exchange on a VPS as a reference point.

Once I missed a few fills chasing the price with change orders, I started laddering different passive limit exits as new orders at different tick intervals. My execution speed has improved by a significant magnitude because of this.

But there is a big time downside with this... I am using the unmanaged approach and coding this type of complexity has been fairly time consuming to test and debug because you are ultimately left with several unfilled orphan orders and you will have to manage the cancels with custom logic. But if you are up for the challenge and don't mind the headache of going unmanaged and coding some complex order routing, your reward can be 100 to 200 millseconds better execution on every exit.


And one final thing, since you are a fellow NT coder out there fighting the good fight.... The most granular event hander you can use with NT is of course OnMarketDepth so one would think that it would be best to use this capture price level changes for example: marketDepthUpdate.Bid. But in actuality the OnBarUpdate events front run the OnMarketData and OnMarketDepth event by sometimes as much as 1 to 2 seconds. Typically this is around 100 millseconds, though sometimes they can be in sync. I have also learned that regardless of what event handler you use to call the OnBarUpdate event. GetCurrentBid() for example, the frequency of the update will always be based on your selected time series. So if you want to capture the price level changes as fast as NinjaTrader is capable of doing it. You have to go with the OnBarUpdate methods of GetCurrentBid() and GetCurrentAsk() and unfortunately you will have to run the time series of Tick and the value of 1 (This is as granular as it gets with NT). The OnBarUpdate method is far less granular that the level 2 method and typically only take an update 1 time for every 10,20, 50 updates you get with level 2 data, but when a price level ever changes this will always update first.

Also stay away from OnPositionUpdate events and always go with OnOrderUpdate because this will be significantly faster to capture your order state changes.


If you add all these little things up you are likely going to gain 1 full second and that makes all the difference in the world using limit orders chasing exits.


Best of luck!

Ian

These are awesome insights Ian, many thanks.

Started this thread Reply With Quote
  #7 (permalink)
 
aquarian1's Avatar
 aquarian1 
Point Roberts, WA, USA
 
Experience: Advanced
Platform: IB and free NT
Broker: IB
Trading: ES
Posts: 4,034 since Dec 2010
Thanks Given: 1,509
Thanks Received: 2,593

One thing to be aware of is non-reviewable ranges.
For ES it is 6 pts I believe.
If your order gets to the exchange and the price has fallen more than that it is rejected as too far off the market.
This happens to market stop orders in a very fast fall.

For this I would recommend staggered OCA stop-limit orders

..........
peace, love and joy to you
.........
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #8 (permalink)
 tpredictor 
North Carolina
 
Experience: Beginner
Platform: NinjaTrader, Tradestation
Trading: es
Posts: 644 since Nov 2011

You might look at options trades and/or using position size to manage risk instead. For active futures trader, checking calendar first and not trading outside regular market hours will reduce much of the risk. Be aware of general times reports are released helps also. For example, with ES, I think 8:30 is common release time for certain reports because it is pre-market and a report then that is a very risky period to trade.

Reply With Quote




Last Updated on April 19, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts