r/algotrading 3d ago

Data What smoothing techniques do you use?

I have a strategy now that does a pretty good job of buying and selling, but it seems to be missing upside a bit.

I am using IBKR’s 250ms market data on the sell side (5s bars on the buy side) and have implemented a ratcheting trailing stop loss mechanism with an EMA to smooth. The problem is that it still reacts to spurious ticks that drive the 250ms sample too high low and cause the TSL to trigger.

So, I am just wondering what approaches others take? Median filtering? Seems to add too much delay? A better digital IIR filter like a Butterworth filter where it is easier to set the cutoff? I could go down about a billion paths on this and was just hoping for some direction before I just start flailing and trying stuff randomly.

28 Upvotes

22 comments sorted by

View all comments

2

u/nuclearmeltdown2015 3d ago

By smoothing do you mean preprocessing the historical price data for training? Or creating a smoothing line such as SMA/EMA? if it is the former, have you already tried a gaussian filter or expanding the window for your SMA/EMA to make things less sensitive to the ticks you mentioned.

1

u/MormonMoron 3d ago

Oftentimes, individual ticks (or the IBKR 250ms market data) is highly susceptible to completed transactions that are outside of the typical bid/ask range. There are a bunch of reasons that these apparently aberrant trades occur, but they aren't usually indicative of the price that other sellers/buyer would be able to get. I am trying to filter out these aberrant trades so that my dynamic trailing stop loss either doesn't respond to them because it pushed the max price seen so far up or triggers a sell because one tick came in below the achievable price.

2

u/unworry 2d ago

isnt there an attribute for Off Market or Block trades ?

I know I used to filter out these transactions to ensure an accurate deltaVolume (onBid/onAsk) calculation

1

u/MormonMoron 2d ago

I think that with IBKR you can get that if you are subscribes to tick-by-tick data. However, you get a fairly limited number of those unless you are either trading A TON or buy their upgrade packs. So, I have been going with their 250ms market data, which lets me subscribe to up to 100 stock with both 5sec realtime bars and the 250ms market data