This is a topic that I think is very critical to every trader but is often overlooked. So I just wanted to kick this off as an open discussion so we can share ideas, strategies and gain some best practice insights on how to improve this statistic.
For the uninitiated: A toxic fill is when you get your limit order filled simply as a function of the price level immediately moving against you. You are essentially in the very back of the queue on the side that breaks, so you have no time to react and you are immediately down 1 tick upon getting filled.
I have spend quite a bit of time on this particular subject over the last 2 months and have found some very solid ways to quantify toxic fills. So for those not tracking this metric, here are two solid general approaches to quantifying this.
Method 1: Binary Outcome: Either Positive (Non Toxic) or Negative (Toxic)
You need 3 basic types of variables:
a. A variable to track the limit price
b. A variable to to turn on and off the tracking mechanism of the code
c. A variable to hold the outcome of the test. (Was this a toxic fill or not)
1. When you enter a trade you will need to assign two variables. One to hold your limit order price and one to turn a bool flag on to start tracking your progress. For example you would set entrybid = GetCurrentBid() and Tracker = true
2. Using a very granular event handler like OnMarketData or OnMarketDepth, you can track your first price level change after your entry fill with logic like this:
(or if you have a small enough time series (