Walk Forward freezes after first rep
Forums › ProRealTime English forum › ProOrder support › Walk Forward freezes after first rep
- This topic has 18 replies, 4 voices, and was last updated 5 years ago by
nonetheless.
-
-
01/01/2020 at 8:43 PM #115690
Hi, below is a simple strategy I’m working on for the DJI based on Supertrend on a 2h timeframe and the trailing stop on 5m. The optimized results look OK, but I’m having trouble with the Walk Forward; it does one rep then freezes – ie progress shows 100% of the first rep and then nothing happens, doesn’t move on to the next rep. I haven’t had this problem before, what am I doing wrong?
2nd Q: I wanted to test this with CumulateOrders = true, ie to buy another contract each 2hrs that conditions hold but simply changing ‘false’ to ‘true’ gives a nonsensical result. Is there something else that needs to be stipulated? Couldn’t find anything helpful in the manual.
Final Q: how many optimization variables need to be included in the Walk forward analysis to give a meaningful result? I’m guessing that more is better, but considering the time it takes to run, is there some kind of optimum out of the 10,000 possible?
Many thanks in advance!
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivateddaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0TIMEFRAME(120 minutes)indicator1 = SuperTrend[mult,nbr]c1 = (close > indicator1)c2 = (close < indicator1)TIMEFRAME(5 minutes)IF C1 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETSET STOP %LOSS stlENDIF// Conditions to exit long positionsIF C2 THENSELL AT MARKETENDIF// Conditions to enter short positionsIF C2 AND not daysForbiddenEntry THENSELLSHORT 1 CONTRACT AT MARKETSET STOP %LOSS stsENDIF// Conditions to exit short positionsIF C1 THENEXITSHORT AT MARKETENDIF//trailing stop functiontrailingstart = trstr //trailing will start @trailinstart points profittrailingstep = trst //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//************************************************************************01/01/2020 at 9:45 PM #115693progress shows 100% of the first rep and then nothing happens,
I’ve set up your code with variable values and it has gone through 5 stages of WF.
However, it would be much more useful if you posted the .itf file with the variables you set up as then I can do a WF on the same file that your WF failed on??
01/01/2020 at 10:32 PM #115698Thanks GraHa, here’s the itf.
01/01/2020 at 10:43 PM #115700how many optimization variables need to be included in the Walk forward analysis to give a meaningful result? I’m guessing that more is better
Nope: Less is more. If you want to create a completely curve fitted strategy then start with a lot of variables and optimise them with as many values as possible. There is a very good chance that you will find a set of values that gives you an acceptable equity curve. Then adjust just one variable by a value of one and the whole thing is likely to collapse around your ears.
01/01/2020 at 10:57 PM #115702Thanks Vonasi, I am still trying to get my head around all this. I understand that optimization gives a curve-fitted result, but I thought the whole point of WF was to step back from that to something less specifically optimized but generally more robust. For that I have to give it some variables to work with, the question is how much range to include? Is there any rule of thumb for this?
01/01/2020 at 11:34 PM #115704Well @nonetheless your .itf file worked fine on Walk Forward (WF) for me … 5 stages all as normal.
I will say though that this is the first System I have ever done a WF on where the values of 4 variables result in the same set of values (50,20,70,3) for all 5 IS stages. The ranges on your 4 variables are narrower than I normally set up, but probably the narrower range is better.
Also the result is slightly better than with the values you had which presumably you had arrived at by optimisation over the whole 10K IS period??
I’m setting the System going on Demo Forward Test tonight!!
Keep em coming, glad to help you!
01/01/2020 at 11:42 PM #115705There is a lot of stuff on the forums about walk forward to read. In its basic format walk forward is that you develop your system on a section of in sample data and then forward test it on a different section of different data to see if it still works or fails. Then there is walk forward with optimisation of variables and this really just shows you which set of values worked best on each set of in sample and out of sample data if you break the data that you have down into many smaller segments. If all the values are the same then ‘Bingo!’ you (might) have hit the jackpot and those same values might just work in the future too. If they vary wildly then you are most likely curve fitted.
That is a very basic description of walk forward testing!
01/01/2020 at 11:42 PM #115706Hi nonetheless
I ran the walk forward on your code and looking at the positions graph it seems to always have a position open, although the report will show a profit you should consider the over nighting fees which based on this back test would I think leave the system with a loss if used live
01/01/2020 at 11:54 PM #115708you should consider the over nighting fees which based on this back test would I think leave the system with a loss if used live
Surely overnight fees would be 0.01%? So < £3 per night, < £100 per month with Lot size = 1.
My BT results show a profit of £833 in 22 days.
01/02/2020 at 10:16 AM #115733Well @nonetheless your .itf file worked fine on Walk Forward (WF) for me … 5 stages all as normal. I will say though that this is the first System I have ever done a WF on where the values of 4 variables result in the same set of values (50,20,70,3) for all 5 IS stages.
Thanks for that, it’s a mystery why it won’t run for me. Tried it again this morning and same result. But good to know that it checks out for you. Do you remember by chance what the % efficiency reading was? And just to be clear, you’re running it with Supertrend [5,20] and trailing stop 70 with step 3?
01/02/2020 at 10:59 AM #115736In its basic format walk forward is that you develop your system on a section of in sample data and then forward test it on a different section of different data to see if it still works or fails.
So how do I run WF without optimization? If I have WF Active ticked with no variables in the upper window then I just get a normal backtest.
01/02/2020 at 11:11 AM #115738you should consider the over nighting fees
Yes, the overnight finance charges are hard to account for in backtest. Maybe v11 will have an option for a charge per day under Brokerage fees. But as GraHal said, for a $2 position on the DJI the fees are covered by just 2 or 3 points … not a big ask if you’re on the right side of the trend.
01/02/2020 at 11:20 AM #115740And just to be clear, you’re running it with Supertrend [5,20] and trailing stop 70 with step 3?
Yes it was as above last night, but it has changed slightly today … see attached
what the % efficiency reading was
I ran it again to get the above results for you, but for some weird reason when I click on the Detailed Report … nothing happens, I cannot get a Detailed Report so I can’t tell you what overall WF Efficiency is sorry.
01/02/2020 at 11:30 AM #115744So how do I run WF without optimization?
You don’t,
- You optimise over In Sample (IS) period … say the 1st 70k bars of the 100k bars available to us.
- Then you Walk Forward over Out of Sample (OOS) period of the remaining most recent 30K bars with variables set to optimisation.
If all variables result in the same value for OOS as they did for overall IS … then Bingo (maybe! :)) … as Vonasi described above.
01/02/2020 at 12:07 PM #115749At the 5th attempt the WF worked for me, see attached results. Not brilliant but worth forward testing for a bit, see if it makes money. Thanks again for your help!
-
AuthorPosts
Find exclusive trading pro-tools on