Strategy Analyzer - less trades on longer backtest period than on shorter one

Hello NinjaTrader community,
I’m running a custom strategy based on a custom ZigZag implementation (BetterSwing) that builds a linked list of only completed swings.

The trading logic uses:

  • the latest confirmed swing (Tail)
  • the previous swing (Tail.Previous.GetFibLevel(...))
  • and a HashSet to prevent trading the same swing multiple times.

The problem

When I run the Strategy Analyzer on a shorter date range (e.g. last 25 days), I get more trades in that period.
But when I extend the backtest to a longer range (e.g. last 300 days, which fully contains the previous 25 days), I actually get fewer trades in that same overlapping 25‑day period.

The swings visually look the same on both tests (I verified by plotting BetterSwing on the chart), yet some trades simply don’t trigger in the longer backtest.

My suspicion

I suspect the root cause is still related to BetterSwing and how ZigZag determines completed swings in the context of the entire history.

Even though I only add finalized swings to the list, when the Strategy Analyzer has more historical bars, ZigZag might still resolve previous swings slightly differently (different indices, High/Low times) because it recalculates using the full history.

This would cause:

  • different swing objects → different hashes
  • previous swing references changing
  • HashSet<MySwing> skipping some setups as already “traded”

So on a longer period the Analyzer builds a slightly different internal swing structure, and some trades never appear.

What I’d like to know

  1. Is this expected behavior for ZigZag-based strategies?
    Does extending the date range always lead to recalculation of swing points, even for “completed” swings?
  2. How can I stabilize the Strategy Analyzer results?
  • Should I add a warm‑up period and ignore trades before a specific date?
  • Is there a recommended way to “freeze” finalized swings so they remain identical regardless of the total data range?
  1. Has anyone found a reliable approach to avoid this “path dependency” when using ZigZag / swing‑based logic in Strategy Analyzer?

Additional info

  • I confirmed that the plotted swings look identical on both charts (shorter vs longer range).
  • However, in the longer backtest some trades get skipped because HashSet<MySwing> considers them already processed (probably due to hash differences from earlier history).

Any insights or best practices for stabilizing ZigZag/swing-based strategies in Analyzer would be greatly appreciated!

Thanks in advance!

PS I paste links for codes of that custom indicator and strategy.

1 Like