Fixed vs Adaptive Parameters in Algorithmic Trading - page 2

 
Gio Rendel Masagca Rivadillo #:
Thanks!

You're welcome.

Just to be clear, that's a scalping strategy. We're talking a few points of repetitive leading/lagging many times per day, as opposed to extended leading/lagging for swing trading.

 
To answer Gio's question about an EA "knowing when to adapt" (regime shifts, trend vs mean-reversion): the practical approach is a two-part classifier rather than a single indicator, since one signal alone tends to flip back and forth right at the threshold. ADX(14) on H1/H4 works well to separate trending vs ranging conditions (e.g. above ~25 = trending, below ~20 = ranging, leaving a dead zone in between so price sitting right on the line doesn't cause constant switching). Pair that with an ATR ratio - current ATR vs its own longer-period average - to see whether volatility is expanding or contracting, which tells you a lot about whether a breakout is likely to hold. The part people usually skip is confirmation: only update the regime label after the classification holds for 2 consecutive closed bars, not on every tick or every new bar. That alone removes most of the false regime flips a single-bar read produces. Once the regime label is stable, you don't necessarily need two separate strategy blocks - the same core logic can just scale its position size, SL/TP distance, and entry filter strictness based on the current regime, which is a lot less to maintain than fully separate trend/mean-reversion systems.
 

"but over time it starts to lose its edge because by the time the crossover happens, a big part of the move is already over."

So what's really the problem is that your Fast MA has a period that is too high. Not much to do with lag. 

 

Mobina's regime-classifier answer above is the right shape for this - ADX for trend vs range, an ATR ratio for expansion vs contraction, and confirming over a couple of closed bars so it does not flip on a single read. I would add one caveat that is easy to miss.

A regime filter does not remove the overfitting problem, it relocates it. The ADX threshold, the confirmation bar count, the ATR lookback are themselves free parameters - you have just moved the knobs up one level. It is only a real gain if those meta-parameters are more stable across instruments and time than the EMA lengths they replace. Sometimes they are, sometimes they are not, and the only way to know is to walk-forward the whole adaptive scheme and check it actually beats the best single fixed-parameter version out-of-sample. If it does not clear that bar, the adaptivity is just fitting noise one layer up.

For a near parameter-free version of the same idea, Kaufman's efficiency ratio and his AMA are worth studying - the "adapt without adding new knobs" case, so you are not reinventing it.

And to the original question: I would not expect any single system to perform in every regime. Deciding when it is allowed to trade is usually more productive than trying to make one parameter set fit all conditions at once.

 
I stopped using indicators cause they delay the signal, ending up in worse executions. That's how indicators work mate. You can try to optimize it by having to reduce your RR by widening your stops and see whether it fits. But i highly suggest you switch to pure price action strategies. 
 

A more reliable approach is for the EA to detect the current market regime first. For example, it might use ADX and ATR to classify the market as either trending or range-bound. Once a regime is identified, the EA switches to a predefined set of rules that was already optimized for that environment. So instead of inventing new EMA values on the fly, it's simply choosing between a "trend mode" and a "mean-reversion mode." The regime itself should only be re-evaluated periodically (for example, every few hours or once per session), not every tick.

The important part is that these parameter sets are validated offline using walk-forward testing, then deployed as fixed strategies. The EA adapts by switching between proven strategies, not by continuously tuning itself while trading.

 
Gio Rendel Masagca Rivadillo:

I've been developing trading EAs for about a year now, and one thing I keep running into is the same issue over and over: lagging indicators.

Take a simple trend-following strategy using an EMA Golden Cross and Death Cross. It can perform really well in certain market conditions, but over time it starts to lose its edge because by the time the crossover happens, a big part of the move is already over.


That got me thinking.


Has anyone here experimented with making indicator parameters adaptive instead of keeping them fixed forever? For example, instead of always using EMA 50/200, the EA could continuously adjust those values based on its own internal calculations and recent market behavior. The idea would be for the EA to adapt as the market changes rather than relying on the same settings year after year.

I know this can easily turn into overfitting if it's done the wrong way. The difficult part is finding a way to adapt without simply optimizing for what just happened. I'm curious how more experienced developers here deal with this.


Do you just accept that every strategy will have market conditions where it performs poorly?

Do you use adaptive indicators or self-adjusting logic? If you do, how are you approaching it?

Or have you moved away from traditional crossover systems altogether?


I'd really like to hear how others have tackled this problem or if you've found a completely different way of thinking about it.


The longer I spend building algo trading bots, the more I realize how endless the possibilities are. Every time I think I've seen everything, I come across another idea that I never would have considered.

I once talked to a trader who said he was using satellite images of oil ports and tanker traffic around the world to help predict supply changes before trading oil. My first reaction was that it sounded completely over the top, but the more I thought about it, the more I wondered if there was actually an edge there.

Do you think something like that is realistic for independent traders, or is that the kind of approach that's only practical for institutions with deep pockets?

I'd also love to hear about any unconventional data sources or ideas you've seen people use successfully. The more I learn about algorithmic trading, the more it seems like there really are no limits to where an edge can come from.

We had the same idea on the same day ahaha. Just two days ago I was wondering whether changing the MA periods internally all the time would be a valid concept. I've yet to try it though. Anyway, in my experience, Moving Averages tend to be too overfitted almost always. Especially if you use two or more. If you use only one, maybe it can survive, but I'd suggest higher timeframes for that. I'm currently using an EA with one MA on the H4 timeframe, but with a few filters on and it is working really well. On the lower timeframes, it's so difficult to have consistency over long periods of time with MAs instead. Also, if I may suggest, try avoiding EMAs. They tend to overfit quicker than normal MAs.

Anyway, yeah, I wouldn't suggest MAs in general. If you really want to use a classic indicator, Bollinger Bands are a bit better. Just an hour ago I've finished setting them up for US30 and they work quite great even in an out of sample of 2 years. But they also work great for Gold in these past 2 years as you could see in the backtest pictures of my latest EA for example. So, yeah, Moving Averages are quite a pain. But I'll try making an EA that changes the MA period internally. I've a few ideas in mind to do that. Let's see what comes out.