Download MetaTrader 5

Setting up the optimiser

To add comments, please log in or register
Find and download Code Base apps via MetaTrader. It is fast!
kingkevbo
192
kingkevbo 2013.05.08 14:51 

Hi,

I have written an EA which I have been running in the optimiser. My EA has various inputs, one of which is a boolean whether the EA should use a trailing stop or not, and another is the value of the trailing stop.

What I would like to know is, is it possible to set up the tester, either with settings, or with changes to my code, so that the optimiser doesn't bother to test different values of the trailing stop if the trailing stop boolean is set to false.

Thanks. 

Alain Verleyen
Moderator
30702
Alain Verleyen 2013.05.08 15:34  
kingkevbo:

Hi,

I have written an EA which I have been running in the optimiser. My EA has various inputs, one of which is a boolean whether the EA should use a trailing stop or not, and another is the value of the trailing stop.

What I would like to know is, is it possible to set up the tester, either with settings, or with changes to my code, so that the optimiser doesn't bother to test different values of the trailing stop if the trailing stop boolean is set to false.

Thanks. 

If your code don't use a trailing stop when your boolean is setted to false, then the optimiser either. Actually, I don't understand why you asked.
kingkevbo
192
kingkevbo 2013.05.08 16:20  
angevoyageur:
If your code don't use a trailing stop when your boolean is setted to false, then the optimiser either. Actually, I don't understand why you asked.

Ok, let me clarify. There are around 10 inputs that an be changed for the EA. Let me give an example:

 

Test 1:

Input1: x

Input2: x

....

Input 9: (Trailing stop) True

Input 10: (Trailing stop level) 300 

 

Test 2:

Input1: x

Input2: x

....

Input 9: (Trailing stop) False

Input 10: (Trailing stop level) 300  

 

Test 3:

Input1: x

Input2: x

....

Input 9: (Trailing stop) False

Input 10: (Trailing stop level) 700   

 

In the above examples inputs 1-8 are the same. Test 1 will give different results to tests 2 and 3, as test 1 uses a trailing stop. Tests 2 and 3 will give the same results, as neither uses  a trailing stop, and will take up needless time in the optimisation process. I want to leave input 10 as a variable so different values of it can be tested when the optimiser runs with input 9 set to true, but when input 9 is set to false, varying input 10 will do nothing to the final balance result, but has taken up valuable time and money in the optimisation process. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties - Documentation on MQL5
Alain Verleyen
Moderator
30702
Alain Verleyen 2013.05.08 16:55  
kingkevbo:

Ok, let me clarify. There are around 10 inputs that an be changed for the EA. Let me give an example:

 

Test 1:

Input1: x

Input2: x

....

Input 9: (Trailing stop) True

Input 10: (Trailing stop level) 300 

 

Test 2:

Input1: x

Input2: x

....

Input 9: (Trailing stop) False

Input 10: (Trailing stop level) 300  

 

Test 3:

Input1: x

Input2: x

....

Input 9: (Trailing stop) False

Input 10: (Trailing stop level) 700   

 

In the above examples inputs 1-8 are the same. Test 1 will give different results to tests 2 and 3, as test 1 uses a trailing stop. Tests 2 and 3 will give the same results, as neither uses  a trailing stop, and will take up needless time in the optimisation process. I want to leave input 10 as a variable so different values of it can be tested when the optimiser runs with input 9 set to true, but when input 9 is set to false, varying input 10 will do nothing to the final balance result, but has taken up valuable time and money in the optimisation process. 

If you want to optimize only when Trailing Stop is true then don't use this variable in the optimization (uncheck the checkbox in front a the variable).
kingkevbo
192
kingkevbo 2013.05.08 18:20  
angevoyageur:
If you want to optimize only when Trailing Stop is true then don't use this variable in the optimization (uncheck the checkbox in front a the variable).

I would like the optimisation process to decide for me if using a trailing stop is advantageous or not, therefore I have to allow the optimiser to try both true and false states for all other variable inputs. Its just that when its set to false, there is no point in the optimiser changing the value of the trailing stop as it will have no effect. The optimiser of course has no way of knowing this. What I wanted to know is there any way of telling the optimiser this. I am suspecting not. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties - Documentation on MQL5
Alain Verleyen
Moderator
30702
Alain Verleyen 2013.05.08 18:44  
kingkevbo:

I would like the optimisation process to decide for me if using a trailing stop is advantageous or not, therefore I have to allow the optimiser to try both true and false states for all other variable inputs. Its just that when its set to false, there is no point in the optimiser changing the value of the trailing stop as it will have no effect. The optimiser of course has no way of knowing this. What I wanted to know is there any way of telling the optimiser this. I am suspecting not. 

Ok, I think I understood now ;-)

You can add something like that to your OnInit function :

if (Trailing_stop == false && Trailing_stop_level != 300) return(INIT_PARAMETERS_INCORRECT);
To add comments, please log in or register