How to Determine Whether an EA Relies on Entry Timing: A Backtesting Method That Eliminates Path Dependency

In forex trading, many people encounter a common issue: the same EA sometimes performs exceptionally well, while at other times it performs poorly. In backtesting, it may consistently generate profits, but in live trading, it may quickly experience a drawdown or even a margin call. Many traders tend to attribute this to parameter adjustments or market changes, but in reality, the problem often lies not with the strategy itself, but with a more subtle factor: the timing of entry.

How to Determine Whether an EA Relies on Entry Timing: A Backtesting Method That Eliminates Path Dependency

Introduction

In forex trading, many people encounter a common issue: the same EA sometimes performs exceptionally well, while at other times it performs poorly. In backtesting, it may consistently generate profits, but in live trading, it may quickly experience a drawdown or even a margin call. Many traders tend to attribute this to parameter adjustments or market changes, but in reality, the problem often lies not with the strategy itself, but with a more subtle factor: the timing of entry.

In other words, the same strategy, when executed at different times, may follow entirely different paths. This variation is not due to a change in the strategy’s logic, but rather the result of differing market movements. Often, what traders perceive as “consistent profitability” is merely the outcome of a specific market path, rather than an inherent stability of the strategy itself.


I. The Nature of the Problem

Let’s look at two simple scenarios.

Scenario A: Starting with the wind at your back

When a strategy is launched at the beginning of an uptrend, it can typically generate profits quickly. As profits accumulate, the account begins to build up a certain “cushion.” Even if the market subsequently experiences a pullback, the strategy can withstand the risk by relying on its existing profits; as a result, the overall performance curve appears stable with minimal drawdowns, leading investors to mistakenly believe the strategy is very safe.

In this situation, the risk hasn’t disappeared; it’s simply been masked by earlier profits. In other words, the strategy appears “stable” not because it is inherently low-risk, but because it has already “had a winning streak.”

An upward trend at the time of entry



Scenario B: Starting Off on the Wrong Foot

If a strategy is initiated during a volatile or downtrend phase, it may incur consecutive losses right from the start. Since the account has no profit buffer, drawdowns are magnified immediately, risks are quickly exposed, and in severe cases, this may even lead to a margin call.

In this scenario, issues with the strategy are exposed early on rather than remaining hidden. This is precisely why many strategies fail in live trading—not because they suddenly stop working, but because they are executed at the wrong time.

Entered the market during a major pullback



Key Findings

A strategy’s performance depends on the timing of its implementation, not on the strategy’s inherent stability. This is known as path dependence.


II. Problems with Traditional Backtesting

Taking MetaTrader 5 as an example, its default backtesting method has some structural issues. First, profits are reinvested in subsequent trades, creating a compounding effect; as the account balance grows, position sizes also increase, which makes the return curve appear steeper.

Second, backtesting typically starts from a single point in time and cannot account for different market phases, such as trends, sideways movements, and reversals. As a result, the outcomes obtained essentially reflect the performance along a single path, rather than the strategy’s overall performance across various market conditions.

More importantly, existing profits can mask the true drawdown, making the strategy appear more stable than it actually is. This is why many strategies show minimal drawdowns in backtesting but perform poorly in live trading.


A pullback can be simply understood as:

Drawdown = (Peak - Equity) / Peak

Drawdowns are calculated relative to the historical peak net value, not the initial capital. Therefore, when a strategy generates significant profits early on, it may still appear to have a “small drawdown” statistically, even if substantial losses occur later.


III. Solutions and Implementation Details

This issue can be addressed using a simple model: fixed principal and profit separation. In this model, all positions are always calculated based on a fixed amount of capital (e.g., 10,000) rather than the current account balance, and profits are not reinvested in subsequent trades but are instead set aside.

It is important to note that profit withdrawals are only processed after all open positions have been closed (i.e., when there are no open positions). Specifically, when the account balance exceeds the initial capital, the excess amount is treated as withdrawn, and the account is logically reset to the initial capital level to continue operations. This approach prevents changes to the capital structure while positions are open, thereby ensuring that the strategy’s operational logic remains unaffected.

The essence of this approach is to ensure that the strategy operates from the “same risk baseline” in every market move, rather than relying on past profits to underwrite future risks.


To illustrate the implementation more clearly, please refer to the simplified code below:

Example of a Risk Control Model (Fixed Principal + Profit Withdrawal)

double BaseBalance = 10000.0;
bool EnableFixedBalance = true;
double BlowUpMarginLevel = 50.0; // 爆仓阈值(%)

datetime FirstTradeTime = 0;
bool HasWithdrawn = false;

// 记录首次开仓时间
void TrackFirstTrade()
{
   if(FirstTradeTime == 0 && PositionsTotal() > 0)
   {
      FirstTradeTime = TimeCurrent();
      Print("First trade time: ", FirstTradeTime);
   }
}

// 利润抽离(仅无持仓时触发)
void CheckWithdraw()
{
   if(!EnableFixedBalance)
      return;

   if(PositionsTotal() == 0)
   {
      double balance = AccountInfoDouble(ACCOUNT_BALANCE);

      if(balance > BaseBalance)
      {
         double profit = balance - BaseBalance;

         if(!HasWithdrawn)
         {
            Print("Simulated withdraw: ", profit);
            HasWithdrawn = true;
         }
      }
      else
      {
         HasWithdrawn = false;
      }
   }
}

// 爆仓检测(使用保证金水平)
void CheckBlowUp()
{
   double marginLevel = AccountInfoDouble(ACCOUNT_MARGIN_LEVEL);

   if(marginLevel > 0 && marginLevel < BlowUpMarginLevel)
   {
      Print("Blow up detected!");
      Print("First trade time: ", FirstTradeTime);
      Print("Blow up time: ", TimeCurrent());
      Print("Margin level: ", marginLevel);
   }
}

This approach ensures that risk is always calculated based on a fixed capital amount, while also capturing the extreme outcomes of the strategy under various scenarios, thereby providing a clearer assessment of its risk boundaries.


IV. Which strategies carry greater risk?

Particular attention should be paid to a specific type of strategy: those that rely on a “snowballing” structure. These strategies typically aim to recoup losses by continuously adding to positions, causing risk to accumulate over time. Common examples include Martingale strategies, grid strategies, and continuous position-building strategies. A common feature of these strategies is that they often require an initial profit to be generated before using those profits to cover subsequent risks. If initiated during unfavorable market conditions, this structure is difficult to establish, and risks are immediately exposed in the early stages.

Essentially, these strategies are not low-risk; rather, they merely "defer" the realization of risk. Therefore, performing well in backtesting does not guarantee that they will operate consistently whenever they are deployed.


V. How to Determine

If a strategy performs very differently depending on the entry point—generating profits in some scenarios but suffering severe losses or even margin calls in others—and requires an initial profit to operate stably, then it likely relies heavily on the timing of entry.

In other words, if a strategy can only succeed when it gets off to a "good start," then it lacks true stability.

Conversely, if a strategy performs consistently across different launch times, exhibits stable drawdown patterns, and does not rely on past profits for support, it is generally more reliable and better suited for long-term operation.


VI. Conclusion

Strategy performance can be understood through a simple relationship:

Strategy Performance = Strategy Ability (α) + Market Movement (β) + Capital Structure

In traditional backtesting, these three factors are often intertwined. The results traders see reflect not only the strategy’s inherent profitability but also the randomness inherent in market movements, while also being influenced by compounding and leverage. As a result, a single backtesting curve often fails to accurately reflect the strategy’s stability.

The method proposed in this paper essentially aims to achieve one thing: to isolate the effects of path and capital structure as much as possible, allowing the strategy to be run repeatedly under uniform risk conditions. By fixing the principal and removing profits, the amplification effect caused by compounding can be eliminated; by conducting tests with multiple starting points, the randomness associated with a “single path” can be eliminated, thereby making the results more representative of the strategy’s true performance.

Once these confounding factors are eliminated, the relative merits of the strategies become much clearer. Some strategies continue to perform consistently under such testing, while others reveal significant inconsistencies—and this is precisely the key to assessing a strategy’s reliability.


The most important point

The most important point is that a truly excellent strategy should not rely on a lucky start, nor should it depend on a cushion built up from early profits to sustain its performance. If a strategy only appears stable after initially generating profits, then that stability is conditional and not universally applicable.

Before deploying a strategy in live trading, it is more prudent to consider the following question: If this strategy were to be launched from scratch at any given moment, would it still be able to withstand normal market volatility and continue operating without the support of historical profits? If the answer is no, then the strategy’s risk has likely been severely underestimated.Only strategies that maintain relatively consistent performance across different starting points—and do not rely on path-dependent advantages—are more likely to survive in the long term. This is precisely the key to determining whether a trading system possesses true stability.