Technique help to reduce over-fitting
Forums › ProRealTime English forum › ProOrder support › Technique help to reduce over-fitting
- This topic has 63 replies, 12 voices, and was last updated 3 years ago by Paul.
Tagged: overfit, overfitting, robustness
-
-
09/04/2020 at 4:11 PM #143401
You are absolutely right, Nicolas & Vonasi. Thanks for the advice. I’ve oversold the idea 😉
you will also introduce a form of over-fitting by avoiding bad months
Indeed, I think a better use of it should be to avoid “extreme” bad month and “even more extreme” good month, where in total gain it looks nice. The code above should be used to avoid such scenario, and stop the test immediately.
if the results are below what you would be happy to trade then quit the back test to save optimising time
Yes, that’s the idea. If we do not like the system to have consecutive 3 weeks of loss, then stop further testing to make it faster.
09/04/2020 at 5:16 PM #14340509/05/2020 at 4:37 PM #143432Hi guys,
I’m just a novice here still finding my way around but could the issues and differences detailed above just be due to differences in the 10.3 and 11 versions?
At the moment we’re all speaking from our own different experiences on 10.3 and 11 and assuming each of us have the same version ?
Either way thanks for all the valuable ideas and input it really helps me to think outside the box.
09/05/2020 at 5:34 PM #143438Hi,
In my opinion, the information mentioned earlier is applicable to both v10.3 and v11. Although v11 may give more options on optimization, but we still need to look out how to not over fitting and how to optimize faster.
09/05/2020 at 8:06 PM #143444v11 s clearly better for optimization (2d, 3d (love it) and so on) but not available on IG sadly
And sadly we will have always overfitting but we can minimize it. The purpose of it is to have the best correlation with OOS
And I don’t remember this study on Quant where they try to calculate the correlation between overfitting and number of variables but their conclusion was there is always an overfitting
09/09/2020 at 11:06 AM #143708No loosers?
Of course there is losers;- 87 % winners
100 % winners on 100 000 units = Overfitting for me
@dow jones LOL not even.
I consider to sell an algo is a scam because it need always some work and retesting
yet you sell algos on your website?
09/09/2020 at 12:10 PM #14372001/01/2021 at 5:55 PM #155870Sharing the latest version, more complete. Insert it at the end of the strategy.
I used it to make faster optimization…skipping some combinations that I anyway not interested to look at all, e.g. 10 consecutive weekly loss, no point to see this combination.
Sometimes it is also useful during WFA, I have tried to adjust to fit for WFA, but not always accurate, mainly because each cycle of WFA, it restarts the computation, so if the duration of a single WFA being to short, then it will stop the test too early, unless you give more room to the parameter. It also depends on the frequency of the strategy.
E.g. 200k bars for 1 min time frame, 5 iteration, 60/40, so the 1st iteration maybe just 2 months. If too little trades during the 2 months, e.g. if you apply volatility filter during March 2020, strategy trade only 2 trades and loss, then the return can be too little so back test stop. So depends on strategy, you might want to give more room to the parameter, like increase the maxconsecutiveweeklyloss to 3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105capital = 5000quarterlymingain = -20quarterlymaxgain = 300monthlymingain = -15monthlymaxgain = 200weeklymingain = -10weeklymaxgain = 100maxconsecutivequarterlyloss = 0maxconsecutivemonthlyloss = 1maxconsecutiveweeklyloss = 2once lastquarterlycapital = capitalonce lastmonthlycapital = capitalonce lastweeklycapital = capitalonce consecutiveweeklyloss = 0once consecutivemonthlyloss = 0once consecutivequarterlyloss = 0once monthnum = 0once weeknum = 0once daynum = 0runningquarterlyperc = ((strategyprofit - lastquarterstrategyprofit) / lastquarterlycapital) * 100runningmonthlyperc = ((strategyprofit - lastmonthstrategyprofit) / lastmonthlycapital) * 100runningweeklyperc = ((strategyprofit - lastweekstrategyprofit) / lastweeklycapital) * 100//0. Check quarterly not lower than expected profit and consecutive lossif OpenMonth <> OpenMonth[1] and (openmonth = 1 or openmonth = 4 or openmonth = 7 or openmonth = 10) thenquarterlyreturn = runningquarterlyperc[1]lastquarterstrategyprofit = strategyprofitlastquarterlycapital = capital + strategyprofit//total = total + monthlyreturn//count = count + 1//monthlyaverage = total/countif quarterlyreturn < 0 thenconsecutivequarterlyloss = consecutivequarterlyloss + 1elseconsecutivequarterlyloss = 0endif//graph quarterlyreturncoloured(0,120,150) as " Last Quarters % Return"//Avoid to stop in case just started 2 monthnums or lessif (quarterlyreturn < quarterlymingain and monthnum > 2) or quarterlyreturn > quarterlymaxgain or (consecutivequarterlyloss > maxconsecutivequarterlyloss) thenQUITendifmonthnum = 0endif//1. Check monthly not lower than expected profit and consecutive lossif OpenMonth <> OpenMonth[1] thenmonthnum = monthnum + 1monthlyreturn = runningmonthlyperc[1]lastmonthstrategyprofit = strategyprofitlastmonthlycapital = capital + strategyprofit//total = total + monthlyreturn//count = count + 1//monthlyaverage = total/countif monthlyreturn < 0 thenconsecutivemonthlyloss = consecutivemonthlyloss + 1elseconsecutivemonthlyloss = 0endif//alltime = (strategyprofit / capital) * 100//graph runningperc coloured(0,128,0) as "Running % Return"//graph monthlyreturn coloured(0,0,150) as " Last Months % Return"//graph alltime coloured(128,145,150) as "All Time % Return"//graph monthlyaverage coloured(0,0,0) as "Monthly Average %"//Avoid to stop in case just started 2 weeks or lessif (monthlyreturn < monthlymingain and weeknum > 2) or monthlyreturn > monthlymaxgain or (consecutivemonthlyloss > maxconsecutivemonthlyloss) thenQUITendifweeknum = 0endif//2. Check weekly not lower than expected profit and consecutive lossif opendayofweek < opendayofweek[1] thenweeknum = weeknum + 1weeklyreturn = runningweeklyperc[1]lastweekstrategyprofit = strategyprofitlastweeklycapital = capital + strategyprofitif weeklyreturn < 0 thenconsecutiveweeklyloss = consecutiveweeklyloss + 1elseconsecutiveweeklyloss = 0endif//graph weeklyreturn coloured(0,145,150) as " Last Weeks % Return"//Avoid to stop in case just started 2 days or lessif (weeklyreturn < weeklymingain and daynum > 2) or weeklyreturn > weeklymaxgain or (consecutiveweeklyloss > maxconsecutiveweeklyloss) thenQUITendifdaynum = 0endifif openday <> openday[1] and openday[1] <> 7 thendaynum = daynum + 1endif01/03/2021 at 1:31 PM #156079need to adjust it lower, to something between 3 to 10, e.g. 5-21, 6-21. So I guess overall, need to apply accordingly to the goal of the strategy
Please can you expand a little on this. I have been using VRT since yesterday and not getting great results 😟, but I wonder if it is because my strategies are faster than Vonsai and use more trades per day.
i get between 2-3 trades per day on 1 minute timeframe, can you recommend VRT QTY and Random settings please?
01/03/2021 at 3:29 PM #156098I’m not sure if you grasp the mechanism of VRT test, but I think is important to know it first, and in short, ProBacktest is limited by the fact that once a trade is on market, it will not open another trade (unless you activate cumulateorders), so during a trade, you may have another signal, but not taken into account by ProBackTest. Those missing signal could have killed your strategy but you do not know as they were skipped. Thus, VRT is born, to tried to skip some barindex, in order to give opportunity for those missing trades to appear and see if they still work well. (though from software point of view, this can be improved by having multiple instances to monitor per trade, and consolidate each signal that are unique, but I doubt PRT will do that).
I wonder if it is because my strategies are faster than Vonsai and use more trades per day.
There is no problem if you have more trades per day. It is more about if during the VRT test, is your trades reduce drastically? E.g. from total 300 trades to become 50 trades. If it is reduce to 50 trades, are the trades still consistent? If yes, then your PRT result will be still good. If no, the chance of curve fit could be higher, it means you might have few big winners (in relative to your average gain), and since those big winners have disappeared in VRT, then weakness appear. And how big chance of those big winner to appear again in live trading? Without those big winners, is your profit become poor? This is quite subjective, because your strategy might be a scalper, thus more trades are in your strength…then you might consider to adjust the parameters.
can you recommend VRT QTY and Random settings please?
The game is the higher value of QTY, the less trades it will be, after you finalize with QTY, then you try to adjust Random so to have total 100 combinations (as PRT optimization window allows only 100 combinations), so you may adjust to your need, my recommendation is to have at least 100 trades for 1m TF. My preference for 1 min TF strategy is to get a score >60 in QTY 2-10/random 1-10, and further test it with QTY 2-5 /random 1-21 with >70, based on experience from my 1m strategy that have profit in live for sometime. To be honest, running VRT is already the last step, the difficult part is are you willing to give up your strategy if it scores badly, as you might have spent several weeks on it? So even it scores badly, maybe just put it in demo and let it run for sometimes and see. If VRT scores well, at least more confident to put it on live sooner… (and I can tell you for my 1m strategy, I have run many rounds of test, improve, test prove, in VRT, WFA, and other tests 🙂 )
Hope it helps, and don’t hesitate to come back and share your opinion and new findings.
01/03/2021 at 3:51 PM #156100Those missing signal could have killed your strategy but you do not know as they were skipped.
and that’s why often strategies have a big stoploss (= many missing signals) and a smaller profit target and fail live.
maybe if a strategy has a simple fixed stoploss & profittarget (1:1?) , you could test each signal simultaneously (and cumulative) with help of arrays in v11. Now if you have a high winratio, then it’s a true high winratio.
Then after finding best settings go back to non cumulative, add additonal exits such as a trailingstop and the system will be more robust. Doubt it’s possible though.
1 user thanked author for this post.
01/03/2021 at 7:51 PM #156122Thank you @DowJones, That is really really helpful, and also helps explains a few things I hadnt understood before – not because Vonasi didnt explain them, it just that I didnt understand them!
One follow up question though… in Vonasi’s original thread he says..
“…‘Qty’ from 2 to whatever you want and ‘Random’ from 1 to whatever you want (maximum = maximum qty value).”
I understood this to mean that you must not exceed QTY with the random number, which would would make Q=2,5 and R=1,21 invalid?. Do you know why this is?
I “thought” I had a good algo, but on high QTY (2,10+) tests it doesnt perform, however with Lower QTY, such as 2,5 it does (see attached)
With no VRT, it produces 103 trades in my 200k backtest, with higher QTY values, and in all of the results with less than half the trades it performs poorly, however when trades are closer to the actual number it does well, any thoughts on this?
also, is there a reason why you chose 21? and not 25 for Random (or higher)… I ran a test with QTY 2-5 and 1-25 (to get 100 results) and I think the results were pretty good?
thanks again
01/03/2021 at 10:42 PM #156128Not all strategies are suitable for applying the VRT code to and also sometimes the VRT code is applied incorrectly. So without the actual code and seeing how VRT has been applied to it it is very difficult to comment much on the results.
‘Qty’ from 2 to whatever you want and ‘Random’ from 1 to whatever you want (maximum = maximum qty value).
That is how it should be and the values should result in 100 or less optimisation results.
There is no correct set of values – you need to capture as many trades as possible so more tests at more different RANDOM and QTY settings can only be a good thing.
103 trades is not a lot. If they are not on the market for long then the VRT test might not find many new trades and so not tell you very much about your strategy. As I said VRT testing does not suit every strategy and if you have questions about the results then you have to look for reasons why you have those questions. We must question every strategy as much as possible to understand how it works as much as possible before we put a £1 on it.
1 user thanked author for this post.
01/03/2021 at 11:48 PM #156131103 trades is not a lot.
Yeah, sadly I can only access 100k bars of data from IG and as my algos run on 1 min I only get around 4 months of data.
All said, your VRT is excellent and another tool for our arsenal, I just wish it was a little easier to understand for the newer algo coders here. It could just be me, but it certainly wasn’t obvious to me that using the “default” settings wouldn’t be suitable for all algos. I initially felt that just fiddling with the numbers would be curve fitting the anti-curve fitting tool, hah!
Anyway, thanks again everyone. Great community here and all the quick responses from the regs/pros is much appreciated.
01/04/2021 at 12:20 AM #156133 -
AuthorPosts
Find exclusive trading pro-tools on