Two Profitable Strategies for GBP/USD
Well finally I’m getting some useful results as a result of adding the mini-tournaments with the integral validation stage. Here are two strategies trained on 5 minute GBP/USD dollar data for 2006 – 2008 that also show a profit on 2009 data :-
;; Candidate 1 long entry = (- (+ (* (min hour bar) -30) (vol (trunc bid))) (high (- (abs -40) (abs (* bar hour))))) long exit = (- (close (min (abs (+ bar minute)) (* (abs (abs -2)) (if (< (trunc bid) (min -24 bar)) (trunc (low hour)) (+ (vol -7) hour))))) (min120 (min (* (vol (vol (vol 22))) (min (min bar (abs (* minute hour))) (trunc bid))) (- bar (trunc 0.137174))))) short entry = (- (stoch (min (max (max (vol minute) (vol 15)) 37) 47)) (abs (max (trunc (stoch (max bar (vol 23)))) bar))) short exit = (+ (abs (if (and (< 0.702188 bid) (> (+ (abs -39) (max 24 hour)) (trunc (ema60 (* -20 26))))) (+ (trunc 0.403593) (trunc (emalow5 hour))) (max minute (+ bar bar)))) (- (min (trunc ask) (if (and FALSE (= (- hour -32) minute)) 46 35)) (* 33 (if FALSE 0.482923 ask)))) ;; Candidate 2 long entry = (double (max (vol (max minute 20)) bar)) long exit = (emahigh10 (max (trunc 0.859856) bar)) short entry = (stoch (+ (trunc (- (* 0.498268 (stoch minute)) (max bar (vol (+ hour 22))))) (if (< (* bar (- -30 minute)) (* (* (* 22 bar) (trunc 0.041836)) 48)) (* -17 54) (trunc (* bar (max120 (vol 32))))))) short exit = (* (if (= (vol -27) hour) (max (max (if (> minute (vol 19)) 36 -6) (+ hour (min bar (- -9 hour)))) (max (vol 20) (trunc (ema20 (abs 16))))) bar) (sin 0.015177))
The profit is very modest for both at around 1000 pips for the year to the end of September.
Each algorithm (long entry, long exit, short entry and short exit) are used as signals to enter or exit long or short. If the algorithm returns a double value greater than zero it is used as a signal to proceed.
Looking at the 2nd candidate, it is essentially a shorting strategy based on the stochastic oscillator because long entry and long exit will always evaluate to a positive value meaning that any long trades entered (i.e. in the absence of a established short trade) will immediately be exited. This suggests that considerable improvement could be achieved by manually removing the long trading aspect.
It is fairly typical to get nonsense code in the results i.e. conditional code that always evaluates to one particular value because of the nature of the underlying data e.g. checking that a close value is greater than zero which clearly it always will be. I’ve been hand adjusting the winning algorithms before reusing them and I have an automated simplification stage in the processing that looks to remove pointless code where it can. Perhaps it could be reduced by reducing the maximum depth of algorithms. Currently maximum depth is set to 8 which means that you can have a maximum of 8 levels of nesting in the algorithm before shrink mutation is enforced. Perhaps reducing this to say 5 might reduce code bloat without compromising the solution quality – it would certainly speed up processing which is proving an issue again at the moment.
November 17, 2009 | Posted by andrew
Categories:
Tags: |
Hi! I´ve tried a software called “Amibroker” which is very good and when I was faced with speed problems for optimizing variables I´ve found a plugin called IO (intelligent optimizer), which uses two kind of optimizations called Particle Sawrm and Differential Evolution, just as a benchmark, when optimizing a system that Exhaustive search would take 200 years, it solved in 20 minutes. If you try to find this algotithms and work on it, maybe you´ll get a great leap on performance.
Regards,
Guilherme
Thanks for the pointers Guilherme, you are the second person that has mentioned Particle Swarm Optimization to me so this sounds like it is worth investigating. I’ve not heard of differential evolution but it sounds like it must involve GP in some way so I’ll see what I can find on that.
How did you get on trading with Amibroker, was it profitable and do you still use it ?
I´ve worked on it during my vacations, but up till now no code for GP on it. Amibroker allows you to use DLL´s in C or other languages, so you can program it to autotrade your examples in foward test.
Another thing you should try is a Walk Foward test (making the in sample and out of sample data change in a pace i.e: one year of in sample data is used to generate the GP code and tested on 2 months of out sample data, after that you record both results and move the in sample data two months foward now containing the old out of sample data till there´s no more data to process). The out of sample results should give you a more realistic results of the code you generate and you can still use it to reoptimize the code every interval you want .
I like GP also, but my project stopped on paper since I’m not a good coder + not much spare time.
Try putting tie-breaker such as code length (i.e. if tie at same score, longer code = lower ranking). This potentially promotes small, simple code to the top which can speed-up computation.
Hi, Thanks for the suggestion about the tie-breaker. As it turns out I have already done this in my latest fitness function and as you correctly say it does speed up processing by favoring less complex solution.
Hi Andrew,
I stumbled across your site via MaxDama and I must say, you have some interesting posts. I too am starting to fool around with PSO for my forex trading models and would love to see how you make out with that strategy. What made you choose GA’s for trading over a conventional ANN?
Keep up the interesting posts, I’ll be reading.
Hi Tom,
I chose GP over ANN because you can extract the rules from GP and then code them up for MetaTrader or even use them manually whereas with ANN, the rules are deeply embedded in the weights and unobtainable. I also came across some other research that showed that GP was marginally more effective than ANN.
Since I started using PSO, I have made some significant advances and now have one strategy coded up in MetaTrader that shows consistent profit on training and unseen validation data.
Thanks
Andrew
Andrew,
Andrew,
I´m glad to hear that you have a good strategy, as I pointed before you should analyse it using the metrics I´ve mentioned on another post to check Expectancy and maximum drawdown and slope of equity curve.
Another I thing that I noticed before on the first strategies you developed is that you use some TA functions, I suggest you to try find out some strategy using only price action and dynamic support//resistance, this would be more consistent than lagging indicators that could kill your strategy during non trending periods and the signals can be generated before than traditional signals using TA.
If possible publish the training and validation results: pips won/ % profit trades/risk reward ratio
Regards,