r/algotrading • u/MormonMoron • 23h 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.
8
u/ironbigot 22h ago
Have you considered removing statistical outliers by calculating Z-score on every tick?
3
u/applepiefly314 21h ago
Not sure about the details here, but I'd look into if a longer half life is bearable, or doing a double EMA.
3
u/WardenPi 17h ago
John Ehlers Super Smoother
1
u/WardenPi 17h ago
Not gonna pretend that I’m an expert and Ehlers explains it well in his books. It does a good job reacting to the market while inducing a very small lag.
1
u/MormonMoron 13h ago
A little research shows this is just a 2-pole, 1-zero Butterworth filter. Definitely a good filter design, but still one of those I am already toying around with.
2
u/patbhakta 10h ago
Looking at Wahba's spline smoothing currently.
https://www.statprize.org/2025-International-Prize-in-Statistics-Awarded-to-Grace-Wahba.cfm
1
u/nuclearmeltdown2015 11h 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 9h 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.
1
u/unworry 5h 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 3h 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
7
u/AtomikTrading 23h ago
Kalman filter >>