Edit Your Comment
PHP MySQL backtesting results
Jan 25, 2018 at 13:42
Uczestnik z Jan 24, 2018
16 postów
Hello everybody,
I have been programming my own automated backtesting script in PHP MySQL for the past 3 months, mainly because PHP is my thing but also because don't see how the common software can automatically run thousands of tests while I'm away. I have imported all the currency pairs in every timeframe from tickstory. I programmed a crossover strategy which executes via cron every 3 minutes. A currency pair, timeframe, stop loss, take profit and/or trailing stop is generated randomly.
This strategy executes via these rules:
buy (once) when ma50 > ema20 and ma50 > ma200
sell (once) when ma50 < ema20 and ma50 < ma200
Closes sell when new buy signal, closes buy when new sell signal.
So far after a couple of thousand runs the results are pretty much depressing. 😞
My best testrun was with USD/JPY H1 over a period of 10 years and 7 months:
- 2020 trades
- stop loss 26
- take proft 130
- win streak 4
- lose streak 21
- 1% risk per trade based on stop loss
- 21.83% wins
- 0.23% equitygain per week
- profit factor 1.08
I do get much better individual results with some other pairs in a D1 timeframe, like a profit factor of 4.50 but that only generated 80 trades in 10 years so I would have to increase the risk per trade to generate anything significant.
I think I can program just about everything now. If anybody has any advice what my next 10000 strategy runs should be about I'd be very happy to start programming something new.
My ultimate goals is to create something that generates 1 or 2% equity growth per week with a maximum drawdown of 10%.
I have been programming my own automated backtesting script in PHP MySQL for the past 3 months, mainly because PHP is my thing but also because don't see how the common software can automatically run thousands of tests while I'm away. I have imported all the currency pairs in every timeframe from tickstory. I programmed a crossover strategy which executes via cron every 3 minutes. A currency pair, timeframe, stop loss, take profit and/or trailing stop is generated randomly.
This strategy executes via these rules:
buy (once) when ma50 > ema20 and ma50 > ma200
sell (once) when ma50 < ema20 and ma50 < ma200
Closes sell when new buy signal, closes buy when new sell signal.
So far after a couple of thousand runs the results are pretty much depressing. 😞
My best testrun was with USD/JPY H1 over a period of 10 years and 7 months:
- 2020 trades
- stop loss 26
- take proft 130
- win streak 4
- lose streak 21
- 1% risk per trade based on stop loss
- 21.83% wins
- 0.23% equitygain per week
- profit factor 1.08
I do get much better individual results with some other pairs in a D1 timeframe, like a profit factor of 4.50 but that only generated 80 trades in 10 years so I would have to increase the risk per trade to generate anything significant.
I think I can program just about everything now. If anybody has any advice what my next 10000 strategy runs should be about I'd be very happy to start programming something new.
My ultimate goals is to create something that generates 1 or 2% equity growth per week with a maximum drawdown of 10%.
There can be only one
Uczestnik z Jun 14, 2013
130 postów
Mar 15, 2018 at 08:18
(edytowane Mar 15, 2018 at 08:23)
Uczestnik z Jun 14, 2013
130 postów
shotputty posted:
Hello everybody,
I have been programming my own automated backtesting script in PHP MySQL for the past 3 months, mainly because PHP is my thing but also because don't see how the common software can automatically run thousands of tests while I'm away. I have imported all the currency pairs in every timeframe from tickstory. I programmed a crossover strategy which executes via cron every 3 minutes. A currency pair, timeframe, stop loss, take profit and/or trailing stop is generated randomly.
This strategy executes via these rules:
buy (once) when ma50 > ema20 and ma50 > ma200
sell (once) when ma50 < ema20 and ma50 < ma200
Closes sell when new buy signal, closes buy when new sell signal.
So far after a couple of thousand runs the results are pretty much depressing. 😞
My best testrun was with USD/JPY H1 over a period of 10 years and 7 months:
- 2020 trades
- stop loss 26
- take proft 130
- win streak 4
- lose streak 21
- 1% risk per trade based on stop loss
- 21.83% wins
- 0.23% equitygain per week
- profit factor 1.08
I do get much better individual results with some other pairs in a D1 timeframe, like a profit factor of 4.50 but that only generated 80 trades in 10 years so I would have to increase the risk per trade to generate anything significant.
I think I can program just about everything now. If anybody has any advice what my next 10000 strategy runs should be about I'd be very happy to start programming something new.
My ultimate goals is to create something that generates 1 or 2% equity growth per week with a maximum drawdown of 10%.
Hi shotputty,
Love the idea! I'm a programmer myself (although more C# and VB web applications), and I've written a few EA's over the last 3 years. Always chasing that one system that works on any pair, any time-frame.
What you are trying to do is very difficult. The first challenge is working with ANY indicator. Technical indicators like MA's are lagging and will give you more false signals than actual profitable trades. The reason for this is simple. Forex markets are consolidating +- 70% of the time. If you use any trend indicator, like MA's, you will get false signals about 70% of the time. And when markets eventually break out and move, you get your entry late (lagging indicator) and this result in small profits, or even losses.
I've even tried using MA's on multiple time-frames to catch the bigger trends. It works better but you are still stuck with the '70%' where you get false or mixed signals. What I found works for me is using price action and market structure to formulate (a) range-bound and (b)breakout strategies. To maximize profit potential you must cater for the 70% with a range-bound strategy and the 30% with a breakout strategy.
From time-to-time, in my local area (Garden Route, South Africa) I teach people how to trade forex. I've added a few screenshots of how I explain how forex markets are typically is structured, and some examples on how I use price action to make trade decisions. Not trying to sell you anything, I just thought it may give you an idea of what I mean. I found this approach to work better than relying on indicators alone when I code an EA. Not saying my method is the best, just that it gave me better results.
Another tip I can give you that worked for me. I also used fixed SL TP levels in the beginning. I used to calculate dynamic lot sizes based on a maximum risk % of my free margin. But I found this does not work for all currency pairs, and again it can mess with your results when markets are trading sideways.
So the best solution was to wait for entries around key support/resistance levels, and using a max risk% per trade to calculate my lot size, I then used the Daily ATR (Average True Range, e.g. 1xATR) to calculate the SL, which is then placed below/above the support/resistance level. To determine the TP level I search for a support/resistance level at least 3x SL, for a 1:3 Risk/Reward Ratio.
This approach works on any time-frame, any pair... but essentially it is a swing-trading strategy, so you get better results on 15mins to Daily.
Hope this help man, and good luck with developing the automated back-testing system. I think it's a great idea.
Keep it simple, be disciplined, get rich slowly and above all protect your equity!
Jan 27, 2019 at 08:14
Uczestnik z Apr 02, 2018
12 postów
Hello Shotputty,
That is very good, but did you take everything under consideration?
- spread
- Comission
- Currency Conversion, if your Account Currency is in EUR, you BUY GBPJPY, means you Buying GBP and Selling JPY, your profit will be in GBP, then you need to check the currency conversion from that time from EURGBP and convert it into EUR to see whats the profit, MT4 already does this calculations on real time..
Regards
That is very good, but did you take everything under consideration?
- spread
- Comission
- Currency Conversion, if your Account Currency is in EUR, you BUY GBPJPY, means you Buying GBP and Selling JPY, your profit will be in GBP, then you need to check the currency conversion from that time from EURGBP and convert it into EUR to see whats the profit, MT4 already does this calculations on real time..
Regards
Price is King, Volume is Queen, all the rest are just story tellers!
Jan 27, 2019 at 12:44
Uczestnik z Jan 24, 2018
16 postów
I replied something from my phone but it didn't post here. i did take into account the spreads and because of that I skipped all the exotic pairs, they ruined every strategy.
I was wondering since it is 2019 maybe it's a bit late to start with MQL4. If you were to learn a new programming skill now, which would you choose? Maybe C# or Java?
I was wondering since it is 2019 maybe it's a bit late to start with MQL4. If you were to learn a new programming skill now, which would you choose? Maybe C# or Java?
There can be only one
*Komercyjne wykorzystanie i spam są nieprawidłowe i mogą spowodować zamknięcie konta.
Wskazówka: opublikowanie adresu URL obrazu / YouTube automatycznie wstawi go do twojego postu!
Wskazówka: wpisz znak@, aby automatycznie wypełnić nazwę użytkownika uczestniczącego w tej dyskusji.