kreslik.com - Traders Community Forum Index Home Page
 FAQ  •  Search  •  Preferences  •  Usergroups  •  Register  •  Profile  •  My Watched Topics  •  Log in to check your PMs  •  Log in
Calendar 
View next topic
View previous topic

Post new topicReply to topic View previous topicEmail to a Friend.List users that have viewed this topicSave this Topic as filePrintable versionLog in to check your PMsView next topic
Author Message
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Tue May 16, 2006 11:54 pm  Post subject:  MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

Hello,

the main issue that made me to use Tradestation instead of NeoTicker or MetaTrader4 was that only Tradestation offered genetic algorithms for strategy optimizing to date.

Since genetic strategy optimization brings me real cold cash by trading the strategies optimized genetically, I had no intent to change the platform Smile

But, right now I have been told by the MetaQuotes representative that they are working on genetic algorithms in MetaTrader 4! Approximate release date is first of July, 2006. I hope that "approximate release date" means "approximate release date" unlike with Tradestation Securities where "in about six months" translates to "in about 3 years" (personal experience with forex automation within Tradestation).

This means that MetaTrader4 will support this functionality very soon. Given the fact that MetaTrader4 is free (as compared to Tradestation) and its programming language is better than EasyLanguage, I will seriously think about switching to MetaTrader4 afterwards.

Coincidentally, last week I also found out that The Grail genetic optimizer (which is the one I am using and coding for) is going to have a version for NeoTicker in a matter of months.

Thus, MetaTrader4 and NeoTicker are my options beside Tradestation. I am really looking forward to the aspTrader's NeoTicker presentation!

Have a very nice day!

Michal


Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Wed May 17, 2006 8:59 am  Post subject:  Re: MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

Well, it seems that MetaTrader4 won't allow for custom fitness functions with its built-in genetic optimizer:


Originally posted by Lenar, MetaQuotes:
Michal, genetic optimization wont be controlable. Everything will covered inside Tester. The best parameters will be determined by the main result - the accounts` balance.


Optimizing on NetProfit only isn't a very good idea. This approach often produces a jagged equity curve which is not much usable for applying the position sizing algorithms.

Michal


Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
albruno
rank: <50 posts
rank: <50 posts



Joined: 17 May 2006
Posts: 1

usa.gif
PostPosted: Wed May 17, 2006 2:04 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

where is a good place to find more information on genetic optimization?
is that the equiv of the input parameter ranges on Tradestation Strats?


 Gender:Male  OfflinePersonal Gallery of albrunoView user's profileSend private messageSend e-mail
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Wed May 17, 2006 2:26 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

albruno,

it's not only the equivalent to finding the best parameter values, but genetic algorithm (GA) can also find the best trading model.

Let's have a look at this strategy snippet:

Code:
inputs:
   iMAType( 1 ), // 1 to 4
   iMALength( 50 ); // 10 to 90

vars:
   vMAValue( 0 );

if          iMAType = 1 then vMAValue = Average(close, iMALength)
   else if iMAType = 2 then vMAValue = Xaverage(close, iMALength)
   else if iMAType = 3 then vMAValue = WAverage(close, iMALength)
   else if iMAType = 4 then vMAValue = TriAverage(close, iMALength);
   
Buy ("average long") next bar at vMAVAlue stop;


This way, the optimizer will not only find the best value for the iMALength, but also will choose the best MA type iMAType. I call these parameters the model parameters.

This example code is quite plain and it might be optimized by a standard exhaustive optimization methods available in Tradestation. But imagine that you've got 10 input parameters, 5 of them are model parameters and you are trying to come up not only with the best model, but with the best (read: the most robust, not the best profit) parameters, too.

Optimizing only 5 parameters with 100 values for each parameter needs 100^5 = 10 000 000 000 combinations. This cannot be done with exhaustive optimization in Tradestation. On the other hand, genetic algorithm will find a near-optimal solution in a matter of hours.

I will post links to the genetic algorithm resources on the internet in the genetic optimization forum. Anyway, feel free to ask about anything concerning GA.

Michal


Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
Lenar
rank: <50 posts
rank: <50 posts



Joined: 22 May 2006
Posts: 23
Location: Russia
russia.gif
PostPosted: Thu May 25, 2006 10:20 am  Post subject:  Re: MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

michal.kreslik wrote:
Well, it seems that MetaTrader4 won't allow for custom fitness functions with its built-in genetic optimizer:


Originally posted by Lenar, MetaQuotes:
Michal, genetic optimization wont be controlable. Everything will covered inside Tester. The best parameters will be determined by the main result - the accounts` balance.


Optimizing on NetProfit only isn't a very good idea. This approach often produces a jagged equity curve which is not much usable for applying the position sizing algorithms.

Michal


Hi, Michal,

We decided to make some changes. Now genetic optimizator will be contrable. You will be able to choose between:
1. Balance
2. Profit Factor
3. Expected Payoff
4. Maximal Drawdown
5. Drawdown Percent

I`ve attached working screenshot of setup of genetci optimization. After release, this window will be redisigned.

So this option will allow to optimize your stratgies more accurately.

_________________
Best Regards, Lenar Fatkhullin
MetaQuotes Software Corp.
http://www.metaquotes.net

 Gender:Male  OfflinePersonal Gallery of LenarView user's profileSend private messageVisit poster's website
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Thu May 25, 2006 3:58 pm  Post subject:  Re: MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

Lenar, great,

this drop-down menu looks cute. BUT, this is not the best way to select the fitness function. This resembles the predefined, Tradestation-like style of work too much. And you want to do better than Tradestation does, right? Smile

Obviously, there should be a number of predefined fitness functions, like:

- NetProfit/MaxDrawDown
- NetProfit/Margin
- VanTharp Expectancy
- PROM (Pessimistic Return on Margin)
- Profit Factor
- Equity Curve Linear Regression Max Error/StdDev
- Sharpe Ratio
etc.

But to lift MetaTrader to higher grounds and smash the competition flat Smile, you have to give your user the freedom to calculate his own fitness funtion.

If you present the user with only a list of several available options in that cute drop-down menu, it is like going to the supermarket and being able to only choose between:

- package 1: cheese, milk, bread, rice
- package 2: cornflakes, 4 apples, wine, sugar
- package 3: potatoes, beef, ice cream, bacon

Now you're smiling, aren't you? But you offer your user precisely these predefined packages without the option the choose milk and ice cream only.

Fortunately, the solution is quite trivial: instead of offering user the entire formulas as a fitness function, give him the ability to use the building blocks to calculate the fitness instead.

What are building blocks?
- TotalProfit
- MaximumDrawDown
- ProfitFactor
- NumberOfLosers
- NumberOfWinners
etc. etc.

This way, if you want to arrive at a set of input values which produces the most trades and best drawdown to profit ratio, you would enter as a fitness function this simple equation:

FitnessValue = (NumberOfLosers + NumberOfWinners)*TotalProfit/MaximumDrawDown

Genetic algorithm-powered optimizer will then try to maximize the result of this equation.

You may implement this FitnessValue variable assignment either right in the code of the strategy (preferably) or you could offer the user the opportunity to enter the formula before the optimization will be run.

Why it is best to implement the FitnessValue variable assignment right in the code? Since the strategy developer may then use any arbitrary value or command within the confines of MetaTrader4 programming language to calculate his own preferred fitness function. Also, implementing this assignment right into the code will actually save you money because there would be absolutely no need to code any extra new dialogues etc.

For this assignment to work, all the tested variables and values during the testing run should be available for calculation within the code.

Let's say that we would like to modify our fitness function from the above example so that we are interested in arriving at a set of input values that produces the most traders, the best profit/drawdown ratio and also the least StopLoss parameter (we don't want to risk much on any single trade Smile.

The equation might then look like this:

FitnessValue = (NumberOfLosers + NumberOfWinners)*TotalProfit/MaximumDrawDown/StopLossValue

In order to be able to use this construction, the value of the parameter "StopLossValue" needs to be available to the programmer. With every test run, the parameter value will change (the optimizer will pick a new value) and this value needs to be available for the programmer in order to be able to use it in the calculation.

Michal


Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
Lenar
rank: <50 posts
rank: <50 posts



Joined: 22 May 2006
Posts: 23
Location: Russia
russia.gif
PostPosted: Fri May 26, 2006 1:22 pm  Post subject:  Re: MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

Hi Michal,

michal.kreslik wrote:
Lenar, great,

this drop-down menu looks cute. BUT, this is not the best way to select the fitness function. This resembles the predefined, Tradestation-like style of work too much. And you want to do better than Tradestation does, right? Smile

Obviously, there should be a number of predefined fitness functions, like:

- NetProfit/MaxDrawDown
- NetProfit/Margin
- VanTharp Expectancy
- PROM (Pessimistic Return on Margin)
- Profit Factor
- Equity Curve Linear Regression Max Error/StdDev
- Sharpe Ratio
etc.

But to lift MetaTrader to higher grounds and smash the competition flat Smile, you have to give your user the freedom to calculate his own fitness funtion.

If you present the user with only a list of several available options in that cute drop-down menu, it is like going to the supermarket and being able to only choose between:

- package 1: cheese, milk, bread, rice
- package 2: cornflakes, 4 apples, wine, sugar
- package 3: potatoes, beef, ice cream, bacon

Now you're smiling, aren't you? But you offer your user precisely these predefined packages without the option the choose milk and ice cream only.



Yeah, very good example with supermarket.Smile

michal.kreslik wrote:

Fortunately, the solution is quite trivial: instead of offering user the entire formulas as a fitness function, give him the ability to use the building blocks to calculate the fitness instead.

What are building blocks?
- TotalProfit
- MaximumDrawDown
- ProfitFactor
- NumberOfLosers
- NumberOfWinners
etc. etc.

This way, if you want to arrive at a set of input values which produces the most trades and best drawdown to profit ratio, you would enter as a fitness function this simple equation:

FitnessValue = (NumberOfLosers + NumberOfWinners)*TotalProfit/MaximumDrawDown

Genetic algorithm-powered optimizer will then try to maximize the result of this equation.

You may implement this FitnessValue variable assignment either right in the code of the strategy (preferably) or you could offer the user the opportunity to enter the formula before the optimization will be run.

Why it is best to implement the FitnessValue variable assignment right in the code? Since the strategy developer may then use any arbitrary value or command within the confines of MetaTrader4 programming language to calculate his own preferred fitness function. Also, implementing this assignment right into the code will actually save you money because there would be absolutely no need to code any extra new dialogues etc.

For this assignment to work, all the tested variables and values during the testing run should be available for calculation within the code.

Let's say that we would like to modify our fitness function from the above example so that we are interested in arriving at a set of input values that produces the most traders, the best profit/drawdown ratio and also the least StopLoss parameter (we don't want to risk much on any single trade Smile.

The equation might then look like this:

FitnessValue = (NumberOfLosers + NumberOfWinners)*TotalProfit/MaximumDrawDown/StopLossValue

In order to be able to use this construction, the value of the parameter "StopLossValue" needs to be available to the programmer. With every test run, the parameter value will change (the optimizer will pick a new value) and this value needs to be available for the programmer in order to be able to use it in the calculation.

Michal


Ok, Slava STRINGO Starikov, lead programmer of MQL4 said that its very interesting and maybe in future we will build special function FITNESS into MQL 4. But it will be not in current build of terminal defenedly.

Thanks for suggestion

_________________
Best Regards, Lenar Fatkhullin
MetaQuotes Software Corp.
http://www.metaquotes.net

 Gender:Male  OfflinePersonal Gallery of LenarView user's profileSend private messageVisit poster's website
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Fri May 26, 2006 1:30 pm  Post subject:  Re: MetaTrader4 - genetic algorithm optimizer available! Reply with quoteBottom of PageBack to top

Lenar,

you will be the first to do that. So you can imagine what does it mean to be the first in the industry.



Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
Lenar
rank: <50 posts
rank: <50 posts



Joined: 22 May 2006
Posts: 23
Location: Russia
russia.gif
PostPosted: Fri May 26, 2006 2:02 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

Thanks for kind words, Michal.

But... hmm, its not realized yet:)

_________________
Best Regards, Lenar Fatkhullin
MetaQuotes Software Corp.
http://www.metaquotes.net

 Gender:Male  OfflinePersonal Gallery of LenarView user's profileSend private messageVisit poster's website
michal.kreslik
rank: 500+ posts
rank: 500+ posts


Age: 33
Joined: 13 May 2006
Posts: 918
Location: Monte Carlo, Monaco
monaco.gif
PostPosted: Fri May 26, 2006 2:25 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I know, I am posting this to motivate you to do it soon BigGrin


Sagittarius Gender:Male Dragon OfflinePersonal Gallery of michal.kreslikView user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topicReply to topic View previous topicEmail to a Friend.List users that have viewed this topicSave this Topic as filePrintable versionLog in to check your PMsView next topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All times are GMT

Protected by CBACK CrackerTracker
54250 Attacks blocked.
Powered by phpBB2 Plus, phpBB Styles and Kostenloses Forum based on phpBB © 2001/6 phpBB Group :: FI Theme :: Mods and Credits

[ Time: 7.9279s ][ Queries: 18 (3.2765s) ][ Debug on ]