I would like to know if there is some way to adapt the period of a moving average to market conditions like for instance the stop loss can be adapted to market conditions using the average true range. Thanks!
EDIT: As suggested, I add some references and context to my question.
I have a trend following system that in the test period 2009 - 2014, with one hour candles, no parameters to optimize, EUR/USD produces these figures:
Max drawdown -48$ 13% (MAE -74$ 20%)
Number of trades 165 (28/year, 1/week, 1/day)
Percent winning 31%
Annual return 139%
Profit factor 1.99 (PRR 1.56)
Sharpe ratio 0.92
Kelly criterion 0.55
R2 coefficient 0.647
Ulcer index 9.4%
However the same system in 2003 - 2008 makes:
Max drawdown -131$ 158% (MAE -154$ 185%)
Number of trades 212 (36/year, 1/week, 1/day)
Percent winning 19%
Annual return 14%
Profit factor 1.15 (PRR 0.90)
Sharpe ratio 0.27
Kelly criterion 0.39
R2 coefficient 0.110
Ulcer index 68.2%
So I tried to look for an adaptive moving average that adapts to market conditions, I read among others these two references:
http://www.mesasoftware.com/papers/MAMA.pdf (just in case it goes down) https://books.google.com.uy/books?id=_KjOT1b9bfUC&pg=PA113&lpg=PA113#v=onepage&q&f=false
I have tried to reproduce the method of the first link mith mixed results, I tested with EUR/USD and candles of 8 hours this code, sorry for the length, I hope you bear with me:
vars Price = series(price());
Stop = 2*ATR(100);
MAMA(Price,0.05,0.5);
vars MAMAs = series(rMAMA);
vars FAMAs = series(rFAMA);
if( crossUnder(FAMAs,MAMAs) ){
reverseShort(1);//if the Following Adaptive Moving Average crosses under the Mother of Adaptive Moving Averages then I enter long, closing previous short if any
} else if( crossOver(FAMAs,MAMAs) ) {
reverseLong(1);
}
plot("price",Price[0],MAIN|LINE,BLACK);
plot("Mama",MAMAs,LINE,RED);
plot("Fama",FAMAs,LINE,BLUE);
Testing that in 2009 - 2014 gave
Max drawdown -157$ 64% (MAE -159$ 65%)
Number of trades 392 (68/year, 2/week, 1/day)
Percent winning 62%
Annual return 35%
Profit factor 1.15 (PRR 1.00)
Sharpe ratio 0.52
Kelly criterion 0.73
R2 coefficient 0.002
Ulcer index 21.2%
But in 2003 - 2008 it gives
Max drawdown -255$ -1396% (MAE -255$ -1397%)
Number of trades 383 (66/year, 2/week, 1/day)
Percent winning 60%
Annual return -2%
Profit factor 0.99 (PRR 0.85)
Sharpe ratio -0.02
Kelly criterion -0.05
R2 coefficient 0.013
Ulcer index 38.7%
However if I test in 2003 - 2008 with 4 hour candles the results are
Max drawdown -145$ 67% (MAE -146$ 67%)
Number of trades 790 (134/year, 3/week, 1/day)
Percent winning 61%
Annual return 32%
Profit factor 1.10 (PRR 0.99)
Sharpe ratio 0.50
Kelly criterion 0.71
R2 coefficient 0.415
Ulcer index 23.0%
So, even this 'adaptive' moving average needed to be adapted to a different market by adjusting the duration of candles, but I don't know whether this is curve fitting. Is there a way to detect this change in market conditions between 2003 - 2008 and 2009 - 2014 in this test?