You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The Strategy Tester calculates the Sharpe ratio using logarithmic returns of equity per bar (last tick), ignoring bars with no change, and with Rf=0.
Over long periods this method converges with trade-based calculations, but in short periods the difference becomes larger due to sampling and time-scale effects.
To replicate it exactly, use the code from the "Mathematics in trading: Sharpe and Sortino ratios" article and apply annualization according to your data frequency.
That I understand. But again, in the article you mentioned, when using the exact same code (litteraly just downloaded the MACD Sampe Sharpe EA), you can get different results.
Try this: launch an optimisation over a duration of 1 year, you will get the same results as the article.
Then, try launching an optimisation over a duration of 1 month, and the sharpe ratios calculated by the Article's are not the same as the ones calculated by the Strategy Tester.
I would like to replicate the exact same formula and get the exact same results as the strategy tester at any time and over any durations.
Zaky, the formula is exactly the same as in the article.
What you are not replicating is the sampling and annualization used by the Strategy Tester: equity at the last tick of each bar in the backtest timeframe, exclusion of bars with no change, logarithmic returns with population mean and standard deviation, and annual scaling based on the bars-per-year for that timeframe. If you don’t apply those exact conditions, the values will never match in short periods. There is no hidden formula.
Zaky, the formula is exactly the same as in the article.
What you are not replicating is the sampling and annualization used by the Strategy Tester: equity at the last tick of each bar in the backtest timeframe, exclusion of bars with no change, logarithmic returns with population mean and standard deviation, and annual scaling based on the bars-per-year for that timeframe. If you don’t apply those exact conditions, the values will never match in short periods. There is no hidden formula.
But that's the thing. I am replicating the exact same behavior as the Article. I literally just downloaded the files and ran a backtest. One over a duration of a year, and the other over of a duration of a month, absolutely no other changes, exactly the same as the Article. The backtest over a duration of a year yields same Sharpe Ratio by both the bot and the strategy tester. Yet over a duration of a month, that's not the case.
I just want to make a function that retrieves the exact same value as the strategy tester under all conditions.
I want to find a way of retrieving the rectangled value every time, but without using TesterGetStatistics(), as I need it in live (each 5 trades).
"What you are not replicating is the sampling and annualization used by the Strategy Tester: equity at the last tick of each bar in the backtest timeframe, exclusion of bars with no change, logarithmic returns with population mean and standard deviation, and annual scaling based on the bars-per-year for that timeframe." <- But I AM replicating those, the article's code replicates those, and I have just used the article's code with no modification for the screenshot above.
The article states "The obtained custom criterion values coincide with the Sharpe ratio calculated by the strategy tester. Now you know the calculation mechanisms as well as how to interpret the obtained results." That is not the case, not over small durations. I'm asking how to get the same value as the strategy tester during small durations.
Zaky, the Strategy Tester does use the formula described in the article, as Rashid Umarov confirmed. The key difference is that it applies it to its own internal dataset, equity values taken from the last tick of each bar in the tested timeframe, excluding bars with no change, and then annualised.
When you run the same period in your EA, even if you use the article's code without changes, you are feeding the formula with your own collected equity values, which are not guaranteed to match the Tester's internal series exactly. The difference may be only a few points in a few bars, but over a short period this has a big impact on the mean and standard deviation, and the annualisation amplifies it further.
That is why in long periods the results appear to match, but in short periods they do not. Without using TesterGetStatistics() you cannot obtain the exact same value the Strategy Tester shows in all cases, because you do not have access to the exact same input data it uses.
I have already explained the reasons several times and there is no way to get 100% identical results under all conditions without using the Tester's own statistics.
Zaky, the Strategy Tester does use the formula described in the article, as Rashid Umarov confirmed. The key difference is that it applies it to its own internal dataset, equity values taken from the last tick of each bar in the tested timeframe, excluding bars with no change, and then annualised.
When you run the same period in your EA, even if you use the article's code without changes, you are feeding the formula with your own collected equity values, which are not guaranteed to match the Tester's internal series exactly. The difference may be only a few points in a few bars, but over a short period this has a big impact on the mean and standard deviation, and the annualisation amplifies it further.
That is why in long periods the results appear to match, but in short periods they do not. Without using TesterGetStatistics() you cannot obtain the exact same value the Strategy Tester shows in all cases, because you do not have access to the exact same input data it uses.
I have already explained the reasons several times and there is no way to get 100% identical results under all conditions without using the Tester's own statistics.