Hi,
Been doing a lot of work with Genetic Algo Optimizations.. here is a little story of my experiences thus far...
I wrote a decent strategy, and I did an optimization for it, and it looks great. The given strategy offered a buy at market to go long and a sell at market to go short. There were no limits on my order entries.
Then i decided to put limits on my order entries, and wow, what a difference. I then realized that each bar was painted at the close, since i was using 10 min bars, i was missing the "window" of the floor (my buy / sell market trigger) and the ceiling (the limit)..
So what to do? Well, I went to the trusty bar magnifier, and then it helped, but not enough, after all if you are trading aapl, with a market limit order, that stock can really move in 60 seconds... so what to do?
I tried to use tick data. Well, even though I construct my bars using tick data for up to 3 months of back data (this is available from IQFeed, but it will fetch like 1 week of data during market hours, but 3 months of tick data outside of market hours). But sadly, tick data didnt seem to show any results on my backtest even though i am using 10 minute bars constructed from tick data... Question to Multicharts --> how can i use tick data for backtest on a strategy that uses 10 minute bars?
I then decided what I would do is put a "switch" in my code that would be set with a true/false parameter. What i would do is make the strategy use buy or sell market for the position entry with no limit order. I use that to train. But for real trading i set the "switch" parameter to place limit orders for market entry.
I feel that the only way to get a realistic optimization or backtest would be to use tick resolution on my 10 minute bars, but sadly I cannot find a way to do this. Therefore the second best way is to train with your strategy use straight market orders, and when you deploy it you use market limit orders...
** Often when people do a backtest or optimize the strategy looks GREAT, but in real life, it doesnt work so great. I think the reasons for this are outlined above. If you want realistic you must use tick data.
Anyway, thoughts anyone?
Observations and workarounds for Genetic Optimizations..
-
- Posts: 186
- Joined: 10 May 2012
- Has thanked: 14 times
- Been thanked: 11 times
- Dave Masalov
- Posts: 1712
- Joined: 16 Apr 2010
- Has thanked: 51 times
- Been thanked: 489 times
Re: Observations and workarounds for Genetic Optimizations..
Hello KhaosTrader,But sadly, tick data didnt seem to show any results on my backtest even though i am using 10 minute bars constructed from tick data... Question to Multicharts --> how can i use tick data for backtest on a strategy that uses 10 minute bars?
Could you be more precise? What do you mean by "didnt seem to show any results"? You may want to use data2 = 1 tick in your code.
-
- Posts: 186
- Joined: 10 May 2012
- Has thanked: 14 times
- Been thanked: 11 times
Re: Observations and workarounds for Genetic Optimizations..
right now i use data1 of 10 min and data2 as 1 hour. Should i add another data3 with 1 tick and make it invisible? will that cause the backtester to "read" tick datapoints in the chart?
- ABC
- Posts: 723
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 410 times
- Contact:
Re: Observations and workarounds for Genetic Optimizations..
Did you set the Bar Magnifier resolution to 1 tick?
-
- Posts: 186
- Joined: 10 May 2012
- Has thanked: 14 times
- Been thanked: 11 times
Re: Observations and workarounds for Genetic Optimizations..
I did set the bar magnifier to 1 tick when i have 2 timeframes on the chart, 1 hour and 10 mins. and i get no entries or exits on backtesting... if i put bar magnifier to 1 min, i get entries and exits in the backtest.
-
- Posts: 186
- Joined: 10 May 2012
- Has thanked: 14 times
- Been thanked: 11 times
Re: Observations and workarounds for Genetic Optimizations..
Hi,
Ok I put a 3rd Instrument, which holds tick data for the stock. That means the strategy uses 10 min bars, and 1 hour bars, and I then just stuck in 500 tick bars (which the strategy doesnt explicitly use). I decided to run an optimization of only a few parameters. The result was a total of 6816 simulations that needed to be tested by the GA. I have 90 days of data that it is going through. The estimated time of completion on my computer is 20:55:07. Thats almost a full day for under 7000 simulations.
Is there a way to make optimizations faster? I set the magnifier to 1 tick. perhaps I should increase that? What do you recommend?
Am I doing this correctly?
Ok I put a 3rd Instrument, which holds tick data for the stock. That means the strategy uses 10 min bars, and 1 hour bars, and I then just stuck in 500 tick bars (which the strategy doesnt explicitly use). I decided to run an optimization of only a few parameters. The result was a total of 6816 simulations that needed to be tested by the GA. I have 90 days of data that it is going through. The estimated time of completion on my computer is 20:55:07. Thats almost a full day for under 7000 simulations.
Is there a way to make optimizations faster? I set the magnifier to 1 tick. perhaps I should increase that? What do you recommend?
Am I doing this correctly?
- Dave Masalov
- Posts: 1712
- Joined: 16 Apr 2010
- Has thanked: 51 times
- Been thanked: 489 times
Re: Observations and workarounds for Genetic Optimizations..
Hello KhaosTrader,
7000 simulations mean that MultiCharts will backtest the code 7000 times with different parameters. To speed up the optimization you can:
- Increase Bar Magnifier parameter (i.e. to 100 ticks);
- Decrease the data reange;
- Decrease number of simulations;
- Try to disable anti-virus software if you have any.
7000 simulations mean that MultiCharts will backtest the code 7000 times with different parameters. To speed up the optimization you can:
- Increase Bar Magnifier parameter (i.e. to 100 ticks);
- Decrease the data reange;
- Decrease number of simulations;
- Try to disable anti-virus software if you have any.
- signalworks
- Posts: 65
- Joined: 06 Oct 2013
- Location: Germany.Solingen
- Has thanked: 23 times
- Been thanked: 2 times
- Contact:
Re: Observations and workarounds for Genetic Optimizations..
Hello Dave,
I discovered, that the count of generations and population is different from time to time (after a few optimizations or after restart of MC) with the same parameters and settings. What is the reason?
Thanks.
best regards,
Lutz
I discovered, that the count of generations and population is different from time to time (after a few optimizations or after restart of MC) with the same parameters and settings. What is the reason?
Thanks.
best regards,
Lutz
- Attachments
-
- genetic_opt_02_after restart mc.PNG
- (15.25 KiB) Downloaded 688 times
-
- genetic_opt_01.PNG
- (15.12 KiB) Downloaded 653 times