Help with WF
Forums › ProRealTime English forum › ProOrder support › Help with WF
- This topic has 23 replies, 4 voices, and was last updated 5 years ago by Nicolas.
Tagged: walk forward
-
-
08/30/2019 at 6:21 PM #105937
Hello
I need help with Walk forward.
I know there is a video about wf but it is in French and I do not understand a word French.
Then there is an instruction in English that I do not fully master either so I ask a question or two here if it goes well.
I have been told sometimes that my algos are over optimized because I only do a regular back test.
Walk forward is apparently much better.
Trying to put me in mind you do a wf in the simplest way.
I chose 5 repetitions on my wf.
I then get 5 different results on my wf test.
Which one should I choose.
A result of over 50% should be obtained for a robust algo.
The reason I chose 5 reps was because I saw a video here on the forum where you just chose 5 reps.
It’s not easy to be a beginner 🙂
08/30/2019 at 6:23 PM #10593908/30/2019 at 6:31 PM #10594508/30/2019 at 6:50 PM #105946This code is not mine.
Balmora made this code and bullbear modify it.
I would like to see if I can make the code work better without it being over op.
“a” is a parameter in short condition
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//TRADING TIMECtimeA = time >= 150000 and time <= 220000CtimeB = time >= 150000 and time <= 220000//POSITION SIZEPositionSize = 1//STRATEGYONCE PeriodeA = 5ONCE nbChandelierA= 17ONCE PeriodeB = 19ONCE nbChandelierB= 34ONCE lag = 1.5MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO))MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)//BUY CONDITIONSCondBuy1 = ANGLE >= 8CondBuy2 = (pente > trigger) AND (pente < 0)CondBuy3 = average[100](close) > average[100](close)[1]CONDBUY = CondBuy1 and CondBuy2 and CondBuy3 and CTimeA//SHORT CONDITIONSCondSell1 = ANGLE <= - aCondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)CondSell3 = average[20](close) < average[20](close)[1]CONDSELL = CondSell1 and CondSell2 and CondSell3 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSize contract at marketSET STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSize contract at marketSET STOP %LOSS 2ENDIF//TRAILING STOPONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 8 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 5 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 30 // Atr parameter ValueONCE minstop = 0 // Minimum Trailing Stop Distance// TRAILINGSTOP//----------------------------------------------atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstartS = round(atrtrail*trailingstopshort)if trailingStopType = 1 THENTGL =trailingstartlTGS=trailingstartsif not onmarket thenMAXPRICE = 0MINPRICE = closePREZZOUSCITA = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenif MAXPRICE-tradeprice(1)>=MINSTOP thenPREZZOUSCITA = MAXPRICE-TGL*pointsizeELSEPREZZOUSCITA = MAXPRICE - MINSTOP*pointsizeENDIFENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenif tradeprice(1)-MINPRICE>=MINSTOP thenPREZZOUSCITA = MINPRICE+TGS*pointsizeELSEPREZZOUSCITA = MINPRICE + MINSTOP*pointsizeENDIFENDIFENDIFif onmarket and PREZZOUSCITA>0 thenEXITSHORT AT PREZZOUSCITA STOPSELL AT PREZZOUSCITA STOPENDIFENDIF08/30/2019 at 8:18 PM #105953From my Walk Forward my conclusion are that the optimal value for a is very different during a downtrend (a = – 5) than during an uptrend (a = – 75)?
You could monitor trends and adjust value of a accordingly, for example do a WF each weekend.
OR
Use a value a = – 35 as a compromise (midway between 5 and 75) and never re-optimise.
Be great if others came in on the discussion with their views / conclusions?
08/30/2019 at 8:34 PM #10595408/30/2019 at 9:05 PM #105957Stefanb have you tried selecting Swedish as the displayed language (top left of each page when reading English or French Topics on Forums … might be easier / quicker for you to understand? Some words and phrases inevitably will get a bit screwed up.
I have to say though that your comments read like English is your native tongue!
08/30/2019 at 9:08 PM #105958Here’s some discussion on Walk Forward
https://www.prorealcode.com/topic/best-approach-for-walk-forward-testing/
08/31/2019 at 7:40 AM #105966Thanks Grahal for your helpful comments.
This with over-optimization is probably the biggest problem as to why most of the codes in the library do not work.
Have tested a lot of codes, some of which are old and most of them end up working after are made.
It would be very good if someone who is proficient at WF could make as simple an instruction as possible.
Then the quality of the codes here on the forum would be much better and that is what we want.
Still mean a really simple variant.
Attaches a code that is very simple that probably won’t work.
I think it’s a EURUSD 5 min code
How would you who are capable optimize it with WF.
What needs to be optimized in this case can be Stochastic, RSI, SL and TP.
12345678910111213141516171819202122// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.DEFPARAM FLATBEFORE = 080000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 223000// Conditions to enter long positionsindicator1 = Stochastic[14,3](close)c1 = (indicator1 <= 19)indicator2 = RSI[14](close)c2 = (indicator2 <= 35)indicator3 = BollingerDown[20](close)c3 = (close <= indicator3)IF c1 AND c2 AND c3 THENBUY 1 CONTRACT AT MARKETENDIF// Stops and targetsSET STOP pLOSS 40SET TARGET pPROFIT 4008/31/2019 at 9:23 AM #10597308/31/2019 at 1:12 PM #105994Attached is best I can do! Spread = 2 … which may be excessive for eurusd with flatafter 22:30?
No hope for a parameter set to give even half decent results over 100k bars! I tried opti over full 100k bars and also un-anchored wf with 5 x os and is periods, result … no parameter set worth keeping! 🙁
I tried 3 different exit strategies (using stoch, RSI and < MA etc) but in the end the TP and SL gave best results!
So what I am going to do is set attached going on Demo Forward Test and try and remember to re-optimise at least monthly, maybe even every 2 weeks.
Be good for you to go through the same process @Stefanb on a separate SellShort version then combine the two version (Long only and Short only) and see if the combined is better than each separate or at least equal to both added? This is a procedure I do now and again.
Let us know how you get on please?
Info Note:
My view is that just because a strategy cannot perform over 100k bars + does not mean that it is shite! Markets change … what punters see as trigger levels last week they did not use those levels as triggers last year etc, but they may even go back to the old trigger levels next year!
Having done loads of manual trading then we use what worked on the last few trades and this can result in a cadence shift over time in successful trigger values across a particular Market … due to loads of big traders doing the same gig??
Above could be why Library strategies drop off in performance as they move further away from date of entry into the Library?
The values I chose for TP and SL over 10K bars, I do not consider as over optimised due to values over several steps either side of optimal also showing good profit levels and performance stats etc.
08/31/2019 at 2:00 PM #106009This blog post might help you get a better understanding of what is and what is not Walk Forward: How to use the ProRealTime Walk Forward analysis tool – FAQ
and also: Strategy optimisation with Walk Forward analysis
Some topics/discussion tagged “walk forward”: https://www.prorealcode.com/topics-tag/walk-forward/
1 user thanked author for this post.
08/31/2019 at 3:30 PM #106015The best way to think of WF testing is that you are just breaking your strategy down into small sections of data and testing on that data and then comparing the results of each test. If they are similar then your strategy might be quite robust. If you optimize variables in a WF then you are also looking for similarity between each bit of data tested. If all the variables come out close or the same for each section tested then it is far more robust than if they vary wildly.
All WF is really doing is comparing smaller back tests to see how similar to each other they are. Similar = good and very different = bad!
09/01/2019 at 8:42 AM #106051Thanks for all the answers 🙂
So if I want to test how robust a code is, I can do the following.
First, I optimize my algo in a regular back test 70% of the time.
Then I run a WF test with 5 periods and select “active and” Achored.
Also selects 70% in-sample.
If it turns out that the 5 periods have fairly similar results and that all periods have a result above 50%, I have a robust system.
Does this sound ok to you or you have to do the whole optimization in WF.
Should now pour a large cup of coffee and read through the links Nicolas attached:)
09/01/2019 at 9:41 AM #106055What you have described is one way to use WF. Remember that their are various settings that you can change such as number of repetitions and ratio of IS to OS so you might want to try other tests as well as the 70/30 x 5 test. Setting a dummy variable value to test from 1 to 1 or just testing one of your strategies variables with a range x to x and then testing various combinations of %/% x repetitions can give you a good idea of overall robustness.
The 50% level for WF efficiency is also not set in stone. 50% basically means that your strategy was half as good in the OOS periods as it was in the IS period. You might decide that this is not robust enough and strive for greater than 90%. On the other side of the coin a WF efficiency of 150% indicates that your strategy performed a lot worse in the 70% IS periods than it did in the 30% OOS periods which might be of concern.
If you have a strategy that seems to be quite robust in various WF tests and seems to come up with an optimised variable setting within a close range for all repetitions then you will want to use the last chosen variable if you go live as that is the one that has performed the best most recently. Then you will want to re-WF optimise occasionally to decide if you need to tweak the value occasionally.
There is no fixed in stone right or wrong way to use WF and no set of rules as to how it should be used. It is simply a tool that allows us to analyse our strategies and get a ‘feeling’ for how robust they are.
-
AuthorPosts
Find exclusive trading pro-tools on