I have built a trading strategy and also a backtest. The backtest has been a lot of work. I was using mid-prices throughout. It’s based on candles, so I make trading decisions at the end of each bar. Recently I changed it to use the bid and ask. So for example to decide if a trade was stopped out I now use the bid/ask high or low (depending if I’m long or short) of the previous bar, rather than the mid high/low. Now, I’m getting much worse test results. It’s possible that due to complicating the backtest code i have introduced bugs. I am wondering if others are backtesting based on mid rates, and then do a forward test as the main stop/go flag. Intuitively I am thinking that I don’t want to have too much code in the backtest to keep it simple, then do most testing in the forward test. But on the other hand I don’t want a useless backtest since I intend to use it to develop new trading strategies quickly. Have others implemented full stop loss management in their backtests, or is this over complicating it? Have you made simplifications such as using mid-rates rather than bid/ask everywhere?
-
$\begingroup$ I don't know if I can help anyway but what is your average holding period ? In other words, are you buying and selling intraday ? It sounds like that is the case but I wanted to confirm for me and others who may not be sure either. $\endgroup$– mark leedsCommented Jan 4, 2022 at 15:53
-
$\begingroup$ I am looking at several different timeframes at the minute. 1m, 5m, 15m, 1H and 4H ... so yes, all intraday. I should add this is all theoretical at the minute, I am building the algo but I have not placed a single live trade through it because I want to have a solid backtesting capability in place first. $\endgroup$– brownie74Commented Jan 4, 2022 at 16:19
-
$\begingroup$ I'm only looking at EUR/USD by the way. $\endgroup$– brownie74Commented Jan 4, 2022 at 16:47
-
$\begingroup$ @markleeds Reading between the lines, are you saying that above a certain timeframe, it does not matter if using mid or bid/ask? Which timeframe? $\endgroup$– brownie74Commented Jan 4, 2022 at 18:17
-
1$\begingroup$ yes, but, for the time frames you're using, it will matter. When you say, bid-ask , you mea that you sell at bid and buy at ask ? That seems more reasonable to me. You also need to add in some transaction cost number ( for slippage, brokerage etc ). Someone with experience in intraday equities, said that 10 bps for round trip is reasonable. Not sure for currency. Also, you need to approximate how much you can buy in the time you have. You can use the U-shaped volume distribution along with some average trading volume to approximate that. The whole backtest is an approximation in fact. $\endgroup$– mark leedsCommented Jan 5, 2022 at 16:50
1 Answer
I once did a backtest of a very interesting strategy that involved frequently (every few days) trading credit default swaps. If I assumed that I could execute at mid, then the strategy made decent returns. However if I assumed 5 bps bid-ask spread (i.e. only 2.5 bps above and below the mid - somewhat optimistic), then the strategy lost money.
My advice to you is to look at both what your strategy would do if you could execute at mid, and also what it would do if you included the bid-ask spreads that you observe now, or have history for. Further, a stress-test assuming much wider bid-ask is always a good practice.
-
$\begingroup$ Thank you for taking the time to comment. I have observed same thing as you. I would to build my backtest using bid/ask if I can, because its closer to the Production siutation when I put the algo live. So i hopefully reduce my chance of a surprise. $\endgroup$ Commented Jan 5, 2022 at 9:58