Filtering entries of a trend-following strategy

 

Hello everyone!

I am developing a trend-following strategy.

The working principle is quite simple: there is a base moving average (indicating the trend direction) and additional filters - moving averages on several timeframes - the price closes above the filters on the working timeframe - it opens a long position.
The working timeframe is from H2 to H6.
It can open up to 10 long positions along the trend, with the same entry logic for all.
Strict risk rules (fixed SL/TP, BE)
Position exit is slow - using a special trailing stop.

The number of entries is considerable, but due to the high risk-reward ratio, the mathematical expectation is good.
The logic is simple (see the trend - add positions along the trend - exit positions // resilience in a flat market - profit on large trends). The strategy is viable and I would like to improve it.

Several questions have arisen during implementation. Perhaps someone has encountered or worked with similar strategies:

1. Flat market filtering and early trend detection - does anyone have ideas on what could replace or supplement moving averages to reduce false entries?

2. Pyramiding filtering (adding positions) - how to organize position accumulation along the trend while preserving the overall logic?

3. Drawdown compression - it is essential, especially during flat market periods. The question is how to optimally implement going into protection and risk return (what professional solutions exist)?

 
ivanov86:
3. Drawdown compression - it is essential, especially during flat market periods. The question is how to optimally implement going into protection and risk return (what professional solutions exist)?

Forum on trading, automated trading systems and testing trading strategies

If an EA Is Truly Profitable, Why Sell It?

Ryan L Johnson, 2026.06.07 17:17

Here's a little known position sizing method to help with scaling up.

Let's assume that you have a simple entry and exit EA with a profit factor of 1.5, for example:

  1. Run it through the Tester.
  2. Read the Tester Report carefully.
  3. Pay particular attention to the months, days, and hours in which the EA is profitable.
  4. Code a time filter that blocks entries during the worst times in the EA.
  5. Run a fresh backtest with the time filter implemented.
  6. Examine the average count of consecutive loss trades─let's call this "NL".
  7. Code automatic position sizing based on say, 1% of account balance, into the EA.
  8. Code an exception to that 1% position size that triggers when NL+1 occurs (the EA has exceed its average loss count).
  9. Code an overriding minimum position size of say, 0.01, to operate when that exception occurs.

The purpose of that process is to solve the mystery of attempting to predict when the EA's logic will be profitable versus unprofitable. Arguably, the best way to track live prices, spread, slippage, etc. is to simply continue trading. Of course, it's nonsensical to continue on trading as if losing streaks don't exist─hence, the bottomed-out position size at the start of each losing streak. As soon as a tiny trade returns a profit, the balance-based position size is once again in effect. As a result the account balance grows, the default position size grows, the account balance grows─it's a vicious "profit loop." Get ready to add some zeros to the backend of your EA's net profit.


 
ivanov86:
1. Flat market filtering and early trend detection - does anyone have ideas on what could replace or supplement moving averages to reduce false entries?
Trend strength, directional momentum, or checking for significant volume (trading participation).
 
ivanov86:
2. Pyramiding filtering (adding positions) - how to organize position accumulation along the trend while preserving the overall logic?

As you're using only trend filters, you need to define short-term pullbacks that occur above your initial long entry price, and below your initial short entry price, respectively. This can be done using a leading indicator such as a Stochastic oscillator.

If you want to try to kill 2 birds with one stone (in relation to Conor Mcnamara's Post #2), use a Stochastic RSI oscillator instead.

 
Ryan L Johnson #:

As you're using only trend filters, you need to define short-term pullbacks that occur above your initial long entry price, and below your initial short entry price, respectively. This can be done using a leading indicator such as a Stochastic oscillator.

If you want to try to kill 2 birds with one stone (in relation to Conor Mcnamara's Post #2), use a Stochastic RSI oscillator instead.

Regarding pullbacks — 100%, but they will be implemented separately (in addition to trend-following, with their own dedicated total risk and logic). This is as a supplement and diversification (along with the same backreversals).

But right now my brain is hurting from:

  1. How to identify a trend with an adequate number of entries/losses.

  2. How to adequately filter entries during a trend.

I am approaching it fundamentally and mathematically (moving from general to specific):

  1. There is statistics — time interval / number of H2-6 candles over a period and the number of trend moves where we can make money.

  2. Suppose we enter after every green H4 candle — the number of entries decreases.

  3. The candle close must be above a certain moving average — the number of entries decreases. The moving average reflects price direction and the strength of the current candle relative to the chosen period. Possibly add volatility adaptation (MA + ATR).

  4. We open the first position, price moves higher — we add positions along the trend (yes, the average purchase price will be higher, but we can safely use larger risk if the trend confirms; if it doesn't, we risk little).

  5. When to add? Probably when price shows strength and wants to move higher — what signals that? Probably micro breakouts of local levels, breakouts of an MA on the high price with a short period, or price recovery after local pullbacks (where we could also add pullback entries).

  6. Drawdown compression is a survival tool in flat markets. We go into protection, but we also need to adequately restore the risk multiplier to normal. Option — use multi-level compression from total drawdown + additional (parallel) stepwise risk compression during series of stop losses (e.g., 10 stop losses, reduce risk by 30%, do this N times) — with stepwise risk recovery (at minimum when the open position's equity has enough profit to cover the stop loss of a new position with increased risk).

This is a very rough description — I am still searching, so please don't judge too harshly :)

 
ivanov86 #:
This is a very rough description — I am still searching, so please don't judge too harshly :)

No problem. I'm not judging at all. I'm merely providing ideas based on my experience.😉

My EA reduces its position size in flat markets. Your proposed EA reduces risk in flat markets. Six of one... half dozen of the other.

 

MA Stacking. Like EMA 50 > EMA100 > EMA200 Bull
For some this might be too slow, if scalping. So reduce EMA periods. But these periods are good for a well defined trend.
In tight ranges EMAs always start to overlap. Only in trending, they separate.

 

For flat market filtering, ADX is the most direct supplement to your MA stack because it measures trend strength independently of direction — exactly the gap you're describing. A standard setup:

  • Skip new long entries when ADX(14) < 25 (price is ranging, MA signals are noisy)
  • Allow entries when ADX(14) > 25 AND +DI > -DI (trend is both strong and directional)
  • Early detection hint: a rising ADX that just crossed above 20 from below signals a trend building. Some systems use this as a half-size first entry, with full size only after ADX > 25 confirms.

For your ATR idea (MA + ATR volatility adaptation) — the natural extension is to require that the entry candle's body exceeds some fraction of ATR(14), e.g. body > 0.5 * ATR. This filters out low-conviction doji-type closes that technically clear your MA but carry little momentum. On H4 timeframes this alone removes a meaningful portion of false entries in ranging markets.

For pyramiding specifically: adding positions when ADX > 30 AND ADX is rising (compare current vs previous bar) guards against pyramiding into a trend that peaked. A falling ADX while you're still above 25 is an early warning that the move is maturing — reduce or skip the next pyramid add.

These work well layered on top of the MA stack already mentioned in this thread: the MA determines the direction gate, ADX determines whether to trade at all, and ATR body filter determines entry quality within a confirmed trend.

 

The buy trade is taken without trend strength check. See how ADX trend strength can be good to avoid such a loss:


 
You get a buy or sell signal. You make your first entry. The following entries assuming the trend continues will be placed at worst prices. An additional problem is that you will not have a clear risk from your account. Also you will diminish your returns by not risking a predefined percentage when you first got the signal. Instead of pyramiding you better use multiple systems. A simple example would be the Turtle method where with S1 20/10 you risk 1% per trade and with S2 55/20 you risk 1% per trade. You treat these 2 systems as independent. As you can see only the length of the lookback period differs.
 

Most replies covered question 1 (ADX/ATR to gate flat markets), so I'll focus on 2 and 3, where trend-adder systems usually break.


Pyramiding (2): the danger is not when to add, it is that aggregate risk becomes path-dependent and can quietly balloon as you stack. The fix that keeps the "same entry logic for all" property you want is to make each add self-funding - only add the next unit once every open unit has its stop at break-even or better, so the locked-in profit of earlier units covers the stop distance of the new one. Done consistently, total account risk stays near your initial one-unit risk whether you hold 1 or 10 positions: the pyramid can only grow once the trade has already paid for it. That is what lets you size up when the trend confirms without the average-price problem turning into account-level tail risk.


Drawdown compression and recovery (3): a loss-counter ("10 SLs cut 30%, restore after N") works, but you end up hand-tuning thresholds that curve-fit easily, and the restore timing is always too early or too late. A smoother approach scales the risk fraction continuously off the equity high-water mark: risk = base_risk * (equity / peak_equity)^k. It compresses as you draw down and heals as you recover, with one exponent to tune instead of a ladder of step rules - no discrete "protection mode" to enter and exit.


One systems point tying it together: the flat filter (Q1) and the drawdown compressor (Q3) partly solve the same problem. If the regime gate does its job, most flat-market losses never happen and the compressor has little left to do. Stack a heavy loss-counter on a weak entry filter and the two interact - you curve-fit both. I would get the regime filter measurably right first (win rate in trend vs range bars), then add only as much drawdown logic as the residual needs.