More accurate spread for back testing.
Forums › ProRealTime English forum › ProOrder support › More accurate spread for back testing.
- This topic has 8 replies, 3 voices, and was last updated 2 years ago by robertogozzi.
Tagged: capital, equity, gain, performance, Profit, spread, strategyprofit
-
-
02/04/2019 at 3:25 PM #90424
We have all seen how important the value of spread is in our back testing. Forget to back test with it and a strategy looks like the holy grail but then deduct several pips for every trade and it doesn’t look quite so good. One of the limitations of PRT back testing is the fixed spread value as I’m pretty sure the spread in 1985 was not the same size as it is today. So I was wondering if there was a better way to apply spread to our back testing.
I’ve been analysing the DJI daily chart today and I wrote an indicator to compare what happened if you went long after every break of a previous days high or break of a previous days low. There was also a simple only trade if bull market filter. In the indicator there is a simple deduction of a spread amount with every simulated trade.
Here’s the holy grail baseline with zero spread:
Green line is going long after a high break and red is going long after a low break.
With a fixed spread of 3.8 the results looked like this:
We can see what a big effect the fixed spread is having in the non computer trading era right up to the mid 90’s. After then it all starts to turn more positive.
So I then thought I’d see what happens if we calculated our spread in the test for each trade as a percentage of the opening price as this might more closely simulate what value spread has actually been over the years. I’m guessing that spread has increased with price and with volatility. This simple calculation simulates the former at least.
123spread = 0.01517 // % of pricemyspread = (spread / 10000) * openCurrently the DJI spread at the end of day is 3.8 so that is 0.01517% of the current price of 25044.
Here is the results with an ever modifying spread:
That is a much nicer set of equity curves! Maybe we have been throwing away good strategies just because a fixed spread makes them look horrible. Maybe we would do better to leave the PRT fixed spread value at zero and calculate our own spreads in our strategies to use in our back testing?
A rising index is possibly going to be easier to calculate varying spread on than an up and down forex pair where the spread is most likely more volatility based.
Does anyone have any other thoughts or ideas on this subject – maybe a way to incorporate volatility in the spread calculation? Maybe one day PRT could even incorporate a spread based on a calculation as an option for back testing alongside the fixed spread option.
Your thoughts?
03/13/2022 at 1:56 PM #189907I too am looking for this information as I build a system. The ability to “call” spread as a function, or “look-up” this value would be a game-changer for sure. I’ll keep thinking of options. One option would be to look up from a list, however, as the spread varies constantly throughout the day, the list would need to be adjusted each time. Also as you mentioned, the spreads are not consistent over time. They change as the broker reacts to volatility.
I’ll keep working!
03/13/2022 at 6:50 PM #189913thanks for reviving this old post from Vonasi, I hadn’t seen it before. It is an issue I have raised many times: using today’s fixed spread on a 10 year backtest = nonsensical.
I wrote to PRT about it and they suggested using Spread = 0 and Order fee, % per transaction instead … except that it has a minimum of 0.01 per side which is too high. On major indices in open hours, spread is typically around o.oo8 %
So how and where would I add Vonasi’s calculation to my algo?
03/15/2022 at 8:43 AM #189998Hello? Roberto? Anyone?
I can’t get my head around what to do with this formula, where to apply it 🤔🤔🤔
Would greatly appreciate some advice on how to code a custom % spread for backtest, thanks!
03/15/2022 at 11:25 AM #190011I never used it, but I think you could use it this way:
12345678910spread = 0.01517 // % of pricemyspread = (spread / 10000) * openONCE MyCapital = 0ONCE MyEquity = MyCapital + StrategyProfitGain = StrategyProfit - StrategyProfit[1]IF Gain <> 0 THENMyEquity = MyEquity + Gain - myspreadENDIFgraph MyEquityMyEquity is the STRATEGYPROFIT + initial Capital – spread.
2 users thanked author for this post.
03/15/2022 at 1:09 PM #190013thanks Roberto, i knew you’d come through 😁
one more thing though: why (spread /10000) * open ?
if spread is %, shouldn’t it be /100 ?
with positionsize = €1 and (fixed spread = 3.8) then the spread would cost you €3.80 (25044 * 0.01517% … using Vonasi’s index value)
but (0.01517 / 10000) * 25044 = €0.038 (to be subtracted from the gain) ???
1 user thanked author for this post.
03/15/2022 at 3:34 PM #190020I don’t know the reason for 10000. Maybe it’s just a typo for 100.
1 user thanked author for this post.
03/15/2022 at 4:05 PM #190021thanks Roberto – yeah, I think it must be a typo.
But today I see that the spread on the DAX got bumped up to 1.8, a 50% move that has nothing to do with any % of its value. So maybe that correlation is no more reliable than ticking the box for fixed spread.
I’ll write to IG and ask if they happen to know what the spreads were 10 years ago and when they changed … someone must know these things.
03/15/2022 at 5:06 PM #190025Anyway, my opinion is that the PAST spread is of no help.
Backtesting will tell you how the price moves affected your strategy in the past. It’s Pips or Money that count, SPREAD won’t affect it. If 5 years ago spread was 8 points and now it’s 2 points, you should use 2 points, as the backtest will report what would have happened if it were 2 since the beginning. In the future it can be higher or lower, at anytime spread changes significantly you should batcktest again your strategy to cope with it for the future. And it will calculate performance using the future SPREAD even on today’s trades. It’s a simulation for the time ahead, you should only care for correct/incorrect trades.
It may happen that some past trades did not even occur at that time, while the do now, due to spread or volatility or slippage, I think you shoudn’t care. It’s important that your strategy is tested to report performance from the past using TODAY’s settings. Pips/Money earned or lost IS all that you have to care about.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on