- Joined
- 14 July 2020
- Posts
- 35
- Reactions
- 32
I am doing some Amibroker testing, mostly to learn AFL, and I got some results that have confused me. I copied some code from a website to test the optimisation function and I thought it was testing an MA Crossover strategy, ie. buy when the shorter MA crosses up over a longer MA - indicating an uptrend....but the better results were the opposite of what I expected. Is that Mean Reversion?
I'm a noob, so I'm hoping someone can set me straight.
Here's the code (I've removed my comments to keep it clean). I ran it over the last couple of years on ASX200 equities.
//
fastlength = Optimize( "FMA", 100, 5, 100, 1);
slowlength = Optimize( "SMA", 25, 1, 100, 1);
FastMA = MA(C, fastlength);
SlowMA = MA(C, slowlength);
Buy = Cross(FastMA, SlowMA);
Sell = Cross(SlowMA, FastMA);
//
The best results seem to be where when FastMA = 18 and the SlowMA = 3...or numbers similar to that. At first glance, this wsa the opposite of what I expected.
When I backtested it (as opposed to running an optimisation) I looked at some of the individual trades and found that it was buying when the FastMA (eg 18) crossed above the SlowMA (eg 3). This means you're buying as the price has dropped below the longer MA, is that a Mean Reversion strategy?
I'm a noob, so I'm hoping someone can set me straight.
Here's the code (I've removed my comments to keep it clean). I ran it over the last couple of years on ASX200 equities.
//
fastlength = Optimize( "FMA", 100, 5, 100, 1);
slowlength = Optimize( "SMA", 25, 1, 100, 1);
FastMA = MA(C, fastlength);
SlowMA = MA(C, slowlength);
Buy = Cross(FastMA, SlowMA);
Sell = Cross(SlowMA, FastMA);
//
The best results seem to be where when FastMA = 18 and the SlowMA = 3...or numbers similar to that. At first glance, this wsa the opposite of what I expected.
When I backtested it (as opposed to running an optimisation) I looked at some of the individual trades and found that it was buying when the FastMA (eg 18) crossed above the SlowMA (eg 3). This means you're buying as the price has dropped below the longer MA, is that a Mean Reversion strategy?