How to Identify Whether an EA Depends on Entry Timing: A Path-Independent Backtesting Method

How to Identify Whether an EA Depends on Entry Timing: A Path-Independent Backtesting Method

Introduction

In forex trading, many people encounter a common problem. The same EA sometimes performs well and sometimes poorly. In backtesting, it may be consistently profitable, but in live trading, it may quickly experience drawdown or even blow up. Many traders often attribute the cause to parameters or market changes, but in reality, the problem often lies not in the strategy itself, but in a more subtle factor: entry time.

In other words, the same strategy, started at different times, may follow completely different paths. This difference is not due to changes in strategy logic, but rather the result of different market paths. Often, the "stable profitability" that traders see is just the result on a certain path, not the inherent stability of the strategy itself.


I. The Essence of the Problem

Consider two simple scenarios.

Scenario A: Favorable Start

When a strategy starts at the beginning of an uptrend, it can usually generate profits quickly. As profits accumulate, the account begins to have a certain "buffer space." Even if the market later retraces, it can withstand risk with existing profits, so the overall curve appears stable with small drawdowns, leading one to mistakenly believe the strategy is very safe.

In this case, risk has not disappeared; it is merely masked by early profits. In other words, the strategy appears "stable" not because it has low risk, but because it has already "earned a stretch."

入场时持续上升趋势


Scenario B: Unfavorable Start

If the strategy starts during a consolidation or downtrend, it may incur consecutive losses from the beginning. Since the account has no profit buffer, drawdown is directly amplified, risk is quickly exposed, and in severe cases, it may even lead to a blowup.

In this case, the strategy's problems are exposed early rather than hidden. For this reason, many strategies fail in live trading not because they suddenly stop working, but because the timing of the start is different.

入场遇到大回调


Core Conclusion

The performance of a strategy depends on the timing of its start, not on the inherent stability of the strategy itself. This is path dependence.


II. Problems with Traditional Backtesting

Taking MetaTrader 5 as an example, its default backtesting method has some structural issues. First, profits continue to participate in trading, creating a compounding effect. As capital grows, position sizes also increase, making the equity curve appear steeper.

Second, backtesting usually starts from a single point in time and cannot cover different market phases, such as trends, consolidations, and reversals. The results obtained are essentially the performance on a single path, not the comprehensive performance of the strategy under various conditions.

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


Drawdown can be simply understood as:

Drawdown = (Peak - Equity) / Peak
Drawdown = (Peak - Equity) / Peak

Drawdown is calculated relative to the historical peak net value, not the initial capital. Therefore, when a strategy has accumulated significant profits in the early stage, even if large losses occur later, it may still statistically appear as "small drawdown."


III. Solutions and Implementation Details

A simple model can solve this problem: fixed principal and profit extraction. In this model, all positions are always calculated based on a fixed capital (e.g., 10,000) rather than the current account balance, and profits do not participate in subsequent trades but are stripped away.

It is particularly important to emphasize that profit extraction occurs only after all positions are closed (no open positions). That is, when the account balance exceeds the initial capital, the excess is considered withdrawn, and the account is logically restored to the initial capital level to continue operation. This avoids changing the capital structure during holding positions, thus not interfering with the strategy's own operational logic.

The essence of this approach is to allow the strategy to operate with the same risk starting point in each market segment, rather than relying on historical profits to bear future risks.


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

Risk Control Model Example (Fixed Principal + Profit Extraction)

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);
   }
}

In this way, risk is always based on fixed capital, while recording the extreme results of the strategy under different paths, thereby more clearly assessing its risk boundaries.


IV. Which Strategies Are Riskier

Special attention should be paid to a class of strategies that rely on a "snowball" structure. These strategies typically repair losses by continuously adding positions, and risk accumulates over time. Common types include Martingale strategies, grid strategies, and continuous position-building strategies. A common feature of these strategies is that they often need to generate profits first, and then rely on those profits to bear subsequent risks. If started in an unfavorable market, this structure is difficult to establish, and risks are directly exposed early on.

In essence, these strategies are not low-risk; they merely "delay" the release of risk. Therefore, good performance in backtesting does not mean they can operate stably when started at any time.


V. How to Judge

If a strategy performs very differently at different starting points—profitable in some intervals but severely loss-making or even blowing up in others—and must rely on "first profit" to operate stably, then it is likely dependent on entry timing.

In other words, if a strategy only succeeds with a "good start," it does not possess true stability.

Conversely, if a strategy performs consistently when started at different times, has a stable drawdown structure, and does not rely on historical profits as support, it is usually more reliable and suitable for long-term operation.


VI. Summary

A simple relationship can be used to understand strategy performance:

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

In traditional backtesting, these three are often mixed together. The results seen by traders include not only the strategy's own profitability but also the randomness brought by market paths, as well as the effects of compounding and capital amplification. Therefore, a single backtesting curve often cannot truly reflect the stability of a strategy.

The method proposed in this article essentially does one thing: strip away the influence of path and capital structure as much as possible, allowing the strategy to run repeatedly on a unified risk basis. By fixing the principal and extracting profits, the amplification effect of compounding is eliminated; by testing multiple starting points, the randomness of a "single path" is removed, making the results closer to the strategy's true performance.

When these interfering factors are stripped away, the strengths and weaknesses of strategies become clearer. Some strategies still perform stably under such tests, while others reveal obvious inconsistencies, which is key to evaluating strategy reliability.


The most important point

The most important point is that a truly excellent strategy should not rely on a lucky start, nor on the buffer space accumulated from early profits to sustain its operation. If a strategy only appears stable after first making some profits, then this stability is conditional and not universally applicable.

Before deploying in live trading, a more reasonable approach is to think about a question in reverse: if the strategy were started from scratch at any arbitrary point in time, could it still withstand normal fluctuations and continue operating without the support of historical profits? If the answer is no, then the risk of the strategy is likely severely underestimated. Only strategies that maintain relatively consistent performance across different starting points and do not rely on path advantages are more likely to survive in long-term trading. This is precisely the key to measuring whether a trading system possesses true stability.