Skip to main content

The Backtest's Last Candle

Open P/L and closed hits.

Josh avatar
Written by Josh
Updated over 2 weeks ago

We often receive questions about "bugged" backtests where orders, especially trailing stops and take profits, are not executing properly.

Below is an example of such a backtest, where the exit condition is set to take a profit of 4%, but the last candle shows a -49.03% return.

How is that possible? Is that a bug?

The short answer is: No, it's not a bug. This is simply an unrealized P/L. To understand why, keep reading.


As we can see, the last hit in this example is an entry, meaning that a position has been opened but hasn’t been closed yet:

Immediate conclusion: The loss of this trade or candle is unrealized. Since the position is still open, there should be no actual loss to note or calculate.


Here are two more clues that indicate this is an unrealized P/L:

  1. Red: The last hit is hit number 8. At the top of the screen, we can confirm that there are 8 hits in total. However, the bottom hits summary only shows 7 hits (the closed positions) in the strategy performance.

  2. Yellow: The backtest summary shows a 100% winning rate, which doesn’t match the last candle. This discrepancy further suggests that the last candle represents unrealized P/L and that the position has remained open.


Conclusion: The next time you see a significant loss on the last candle of a backtest, don’t worry! It simply means there’s an open position that hasn’t met the exit conditions yet, resulting in an unrealized P/L.


Note: All screenshots and examples are for technical demonstration purposes only. They should not be considered as recommendations for any specific trading strategy, nor do they constitute any form of advice. Please click here for further explanation

Did this answer your question?