Run one trading rule in two backtesters and you will usually get two answers. Not wildly different, just different enough that you can't tell which one to trust.
We had to sort this out for one simple rule, and in the end three engines agreed on it trade by trade: TradingView's Strategy Tester, a backtester of about 60 lines written for the check, and the no-code tool we build. This post is the list of things that had to match before they did. None of them is exotic. All of them move results.
Disclosure: I'm a co-founder of Trend0x, the no-code tool in this comparison. Nothing here is financial advice; backtests describe the past, and trading can lose money.
The rule
Daily candles, long only, one position at a time:
- Entry: the close is above EMA 200 and the MACD line (12, 26, 9) crosses above its signal line.
- Exit: the MACD line crosses below its signal line, or a stop at 2.5 × ATR(14) below the signal bar's close.
- Costs: 0.06 % commission per side plus slippage.
Simple on purpose. Every line of it still hides a choice.
1. When does the order fill?
A rule is checked on a closed bar. The question is where the order fills: at that bar's close, or at the next bar's open.
On daily crypto candles the gap between the two is small most days and large on the days that matter. Pick one and use it everywhere. In Pine, process_orders_on_close=false (the default) fills at the next bar's open. In your own code, it means the signal on bar i uses open[i + 1].
2. Where is the stop measured from?
"2.5 × ATR below entry" has at least two readings: below the signal bar's close, or below the actual fill price. With next-open fills these differ by the overnight gap. We measure from the signal bar's close, and the ATR is the one known on that bar. Write it down, because the other reading is just as natural.
3. Which ATR?
TradingView's ta.atr is a Wilder (RMA) average of the true range, not a simple average. A simple-average ATR gives different stops on every trade, and a few of them will be hit or missed because of it.
The same goes for the first bars of any average: how an EMA is seeded changes its early values. With a 200-period EMA, start counting trades after a long warm-up and the seeding stops mattering.
4. What happens when price gaps through the stop?
If a candle opens below the stop, the fill is the open, not the stop. Engines that fill at the stop price on a gap make every stop-out look a little better than it was.
5. Costs: per side, and in which unit?
Commission is easy if both engines take it per side. Slippage is not: TradingView takes it in ticks, our checker took it in percent (0.05 % per side). On a trade that ends near zero, that difference is enough to flip a small win into a small loss. It did, once (see the table).
Also check the default. A new TradingView strategy has no commission unless you set it.
6. Which data, and from which day?
Spot and perpetual futures of the same coin are different price series. Two exchanges are two more. Pick a venue and state it.
Then check the first candle you actually got, not the period you asked for. In a separate test on gold (the XAUUSDT perpetual, 4h), a "one year" test covered about 265 days: the contract's history on that exchange starts in March 2026. The engine didn't fail; there was simply no earlier data. Both of our engines agreed on 4 trades, and they agreed because both started on the same first candle.
7. Same-bar conflicts and compounding
Two small ones that change the totals but rarely the trade list:
- A stop and a rule exit on the same bar. Decide which wins. Ours: the stop, because it happens inside the bar, before the close that triggers the rule.
- Position size. TradingView compounds "10 % of equity"; a quick checker often uses a fixed amount. Same trades, slightly different totals.
The checker
This is the core of the loop we used, translated to Python. Signals and indicators are computed beforehand; the loop only handles fills.
def backtest(df, entry, exit_rule, atr, k=2.5, fee=0.0006, slip=0.0005): """df: DataFrame with open/high/low/close; entry, exit_rule: boolean arrays.""" trades, pos = [], None for i in range(1, len(df)): bar = df.iloc[i] if pos and i >= pos["i"]: if bar.low <= pos["stop"]: # stop touched inside the bar px = min(bar.open, pos["stop"]) * (1 - slip) # a gap fills at the open trades.append((pos["entry"], px, "stop")) pos = None elif exit_rule[i] and i + 1 < len(df): # rule seen on the close... px = df.open.iloc[i + 1] * (1 - slip) # ...filled at the next open trades.append((pos["entry"], px, "rule")) pos = None continue if pos is None and entry[i] and i + 1 < len(df): pos = {"i": i + 1, "entry": df.open.iloc[i + 1] * (1 + slip), "stop": df.close.iloc[i] - k * atr[i]} # from the signal bar's close return [(e, x, why, x / e - 1 - fee * (1 + x / e)) for e, x, why in trades] The last line returns each trade's result after commission on both sides. Everything in sections 1–5 is in those twenty lines, which is the point: if you can't point to the line that decides it, your backtester decides it for you.
The result
TradingView vs. our checker, Binance spot, daily, full history to November 2026:
| Market | Trades (TV / ours) | Winning trades (TV / ours) |
|---|---|---|
| BTCUSDT | 61 / 61 | 22 / 22 |
| ETHUSDT | 63 / 63 | 24 / 24 |
| SOLUSDT | 36 / 36 | 15 / 15 |
| BNBUSDT | 66 / 66 | 29 / 28 |
| XRPUSDT | 39 / 39 | 11 / 11 |
Every trade list matched. The one difference is a BNB trade that ended within a few ticks of zero: TradingView's 2-tick slippage left it a small win, our 0.05 % made it a small loss (section 5).
Our checker vs. Trend0x, BTCUSDT daily, last 730 days: 16 trades on both, 3 of them winners on both, and the net results within 1.6 % of each other. The remaining gap is slippage and the data source.
A note on what this does not show. Agreement between engines says the rule was computed correctly. It says nothing about whether the rule is any good. That is a separate question, with separate tests.
What we look for in any backtester now
Before comparing results, check that it states, somewhere you can read:
- fill timing (signal bar close or next open);
- what the stop is measured from;
- which ATR and moving-average formulas it uses;
- how gaps through a stop are filled;
- commission and slippage, per side and in which unit;
- the venue, the market type and the first candle actually used;
- what wins when two exits trigger on the same bar.
The no-code tool in this test prints most of these on the result card: fills at the next candle open, the ATR stop measured from the signal candle's close, the candle source, and that funding is not included. That's what made the comparison possible in the first place. If a tool doesn't tell you these things, you can't reconcile it with anything, including itself next month.
If you want to try the same comparison, the rule is published as an open-source strategy on TradingView: Trend Filter + MACD Cross Template. Run it next to your own engine and see which of the seven items you trip over first.
