Hi,
when using the Optimization function, I am able to acquire high Annualized Gains.
I check out the parameters, which were used for the highest gain and then after
CODE:
Please log in to see this code.
I set it manual to the "optimal" value:
CODE:
Please log in to see this code.
This is just an example. But like this I do it with all the parameters. Still the Backtesting result is not equal to the high Annualized Gain from the Optimization function. Often it is significally lower, sometimes even higher, and almost never the same.
Provided these facts, must there be a serious problem in my code? Or is this effect common?
Best regards
Werner
Size:
Color:
Hi Werner,
1. What position sizing are you using and how many symbols are in your DataSet?
2. Is this only the Annualized Gain affected or other parameters, too?
Size:
Color:
Not setting LastPosition.Priority is another possibility.
Size:
Color:
Hello, thank you for the replies.
Position Sizing:
Portfolio Simulation Mode / Percent of Equity = 22,50 / Margin Factor 1,11 to 1. (Preferences: Interest on margin loan amount = 7%)
(I use this margin settings to ensure that in case there are a few dollars missing for a purchase, a margin will be used. But besides that, no margin should be used.)
Dataset:
S&P 100 from Wealth-Data
Data Range:
01.07.2000 to 30.06.2020
Now I had a look at the other results and I can say that not only the Annualized Gain in % changes, also the others like, Net Profit, Number of trades, Average Profit per trade or Maximum Drawdown.
With this settings active, the Optimization function should use them as well, right? So, I wonder why the behaviour seems to be different.
Size:
Color:
Size:
Color:
Hi Eugene,
the problem is arising despite having a position priority. Because of position priority I receive the same results whenever I do the backtesting. But I cannot reproduce the results achieved with optimization. Here is my priority setting:
CODE:
Please log in to see this code.
Best regards
Werner
Size:
Color:
Hi Werner,
1. Although it looks good on the surface, this short code snippet is not enough to tell because e.g. LastPosition can be mistakenly applied in a multi-Position context etc.
2. To reproduce results achieved in an optimization you should double click on its row in the Optimization Results. This opens a backtest with exactly the settings applied. Are you doing this?
3. What kind of optimization are you running (type, parameters, settings) etc.?
Size:
Color:
HI Eugene,
thank you for your message. I think the priority settings works well, as I always get the same results when backtesting.
Yes, when I double click on a row in the Optimization Results, I get exactly this result shown in the results. However, when I put these values into the code, so that they are always used, I get different results.
I put this values in the code either by setting it as the standard value for a parameter:
CODE:
Please log in to see this code.
or I set the variable directly:
CODE:
Please log in to see this code.
I am running "Monte Carlo" with "APR%" to be optimized with very different settings for number of runs and number of Tests in reach run.
Werner
Size:
Color:
Hi Werner,
QUOTE:
Yes, when I double click on a row in the Optimization Results, I get exactly this result shown in the results.
Great. At least everything is fine about this (crucial) aspect then.
QUOTE:
I am running "Monte Carlo" with "APR%" to be optimized with very different settings for number of runs and number of Tests in reach run.
What Scorecard are you optimizing and against and what APR% / Annualized Gain numbers you are comparing to in what Performance visualizer? Screenshots might help. If you decide to attach, make sure the left-most pane with strategy parameters and settings (position sizing, data loading and DataSets) are visible.
Size:
Color:
Hi Eugene,
thank you very much for your help and your efforts. I found out what the problem was. It was my mistake. You were right, it had to do with priority setting. My code was like this:
In the constructor I declared the parameter for the priority optimization:
CODE:
Please log in to see this code.
Then, at the top of the Execute funciton I had this:
CODE:
Please log in to see this code.
And, after that I set the variables for a strategy (the ones I found out through optimization):
CODE:
Please log in to see this code.
But at that time the "RSI.Series" was already set up. So it did not use the value - in this case 167. I could not figure it out as it was correct for the other parameters. So, in the end all I had to do is to put the statement "RSI rsi = RSI.Series(Close, pri_per);" below the setting of the variables.
Thank you very much for your help!
Size:
Color:
Glad to see you've figured out the source of error!
Size:
Color:
Thank you for your help, Eugene!
Size:
Color: