calculation error
Trailing stop (and possibly other stops) are not being calculated correctly when using buy / sell at the current days close option. The error is that the system is using the high of the day that the stock was purchased at the close to calculated the trailing stop instead of using the days closing price to start the trailing stop calculation. This can result in the stop being triggered prematurely when the high is significantly higher than the closing price for that day. I back tested TQQQ from January 2016 to Feb 2023 and there were 6 times this happened. Graphs have been posted with this improvement request.
-
Don R commented
Here is the comparison of how the BackTester is not calculating the trailing stop the same way that Portfolio does. Portfolio calculates the trailing stop based on going forward from the close (3:59 PM) and does not use the intraday high for that day, which is the correct way of calculating the trailing stop. Change the BackTester code so that intraday is ignored on the day the stock is bought at the close to match with Portfolio.
-
Don R commented
I reviewed again and there were actually 7 errors from 2016 onwards.
-
Don R commented
This is critical because it is a calculation error that can significantly effect the back test results. It was suggested that I use buy sell at next days open but it did not perform as well. Attached is the current calculation, corrected trades and buy sell at the next day open results.