Optimization Solution/elimination of unwanted passes at the very beginning of the optimization/ (highly Expert Moderator-Programmer case) - page 2

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
but there should be a list of what passes that has already been tested. maybe it can be used? right?
another question is that: would the position of my parameters (higher in the programming line or being lower) makes any difference in the procedure of fast genetic based (FGB) optimization?
is there any reference (document, article, etc) on how FGB of meta trader procedure is? (how it works, how to make it better, what are the critical lines , . . .)
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer - MQL4 Articles
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer - MQL4 Articles
thank a lot
Hello Everyone
I have a problem in optimization passes. I've searched a lot but none of questions nor the answers in the forum was the one solving this problem.
The problem is that I have some Boolean parameters in my inputs which when they are set as false there is no need to optimize some other parameters.
for example, if the "Psar_Active" parameter is set to false my EA won't use Parabolic SAR indicator in its decision-making process,
so optimizing the related input parameters of the indicator "step" and "max" is useless (only when the Activation parameter is false).
Unfortunately, I couldn't find a way for this. so many of the optimization results are useless
and this make the whole optimization much much less effective. (when using the genetic based algorithm)
Let’s assume that "Step" Parameter has 5 different steps and "Max" Parameter has 4 different steps the total steps considering the
"Psar_Active" parameter (which has two steps) is currently resulting to 40 passes (5*4*2), which 19 of them are useless
(the ones with "Psar_Active" ==false). if this problem could be solved the total passes should be reduced to 21 (5*4*1+1).
The solution should be able to solve the problem for multiple parameters.
for example, if the Psar_Active==false Parameters Step & Max should not be optimized
but at the same time ADX_Active==true Parameters Period & Min should be optimized.
so if number of passes are as follow
Psar_Active 2
Step_Psar 5
max_Psar 4
ADX_Active 2
Period_ADX 3
Min_ADX 4
the total passes should be [(1*5*4+1)*(1*3*4+1)]=273 which at the current time the program uses (2*5*4*2*3*4)=960 which 687 passes (%72 of the total calculations made by the agents!!)
are totally useless and misguiding in the genetic base decision making progress.it should be noted that the ones with the false entry should not be totally eliminated.
It's not really important that the total number of passes shown correctly in the input tab of the program, but if the figure is calculated correctly it will be comforting.
but when the optimization is run, there should not be any unnecessary passes in the results (slow complete method or fast genetic base)
I've wrote this problem later on forum but there were not much of help.
https://www.mql5.com/en/forum/298982
I'm not sure which way will do but i assume that writing a function in the tester sections with some parameters that
one of the is them input parameter of EA and the other one a Boolean parameter which determines the necessity of optimization
(or any solution that changes the total number of passes in optimization) can solve this problem. perhaps a remove duplicate kind of function
at the begging of the testing session should be implemented (if all the other -non relative-parameters are the same there should be only one pass
with the false input for that parameter).
usually relative parameter won't exceed more than 10 parameters.so the function should be something like:
void Remove_Unnecessary_Optimize(bool Main_input, Raltive_Paramer1, altive_Paramer2, . . . .,altive_Paramer10)
so far, I couldn't find anyway with this and I don't intend to get anything for free.
please advise me if you can help on this.
thank in advance for your help.
This is how I got around the issue you are having without using INIT_PARAMETERS_INCORRECT and potentially affecting the outcome of my Genetic backtest or by resorting to creating a set file for every possible viable combination of my input parameters and writing another program to run backtesting on each of those set files individually as previously reported as potential viable solutions to the issue at hand.
1) separate your input parameters which you'd like to apply a kill pass to into different groups. Lets say in one of those groups you have 5 or 6 variables, each of which can have two potential inputs in one of those groups.
2) enter each of those variables and their potential inputs in an excel column as shown below:
3) Modify and use the following excel visual basic and run it on the data you just entered to create every combination of those 5 or 6 variables.
Sub ListAllCombinations()
'Updateby Extendoffice
Dim xDRg1, xDRg2, xDRg3, xDRg4, xDRg5, xDRg6 As Range
Dim xRg As Range
Dim xStr As String
Dim xFN1, xFN2, xFN3, xFN4, xFN5, xFN6 As Integer
Dim xSV1, xSV2, xSV3, xSV4, xSV5, xSV6 As String
Set xDRg1 = Range("A2:A3") 'First column data
Set xDRg2 = Range("B2:B3") 'Second column data
Set xDRg3 = Range("C2:C3") 'Third column data
Set xDRg4 = Range("D2:D3") 'Fourth column data
Set xDRg5 = Range("E2:E3") 'Fifth column data
Set xDRg6 = Range("F2:F3") 'Sixth column data
xStr = "-" 'Separator
Set xRg = Range("H2") 'Output cell
For xFN1 = 1 To xDRg1.Count
xSV1 = xDRg1.Item(xFN1).Text
For xFN2 = 1 To xDRg2.Count
xSV2 = xDRg2.Item(xFN2).Text
For xFN3 = 1 To xDRg3.Count
xSV3 = xDRg3.Item(xFN3).Text
For xFN4 = 1 To xDRg4.Count
xSV4 = xDRg4.Item(xFN4).Text
For xFN5 = 1 To xDRg5.Count
xSV5 = xDRg5.Item(xFN5).Text
For xFN6 = 1 To xDRg6.Count
xSV6 = xDRg6.Item(xFN6).Text
xRg.Value = xSV1 & xStr & xSV2 & xStr & xSV3 & xStr & xSV4 & xStr & xSV5 & xStr & xSV6
Set xRg = xRg.Offset(1, 0)
Next
Next
Next
Next
Next
Next
End Sub
You should have a column of all possible combinations of your variables created as shown below.
4) Now using the Text to Columns function of your excel under Data tab, separate all the combinations into individual columns.
5) Using If statements, apply whatever rules you want to eliminate the rows with variables you do not want to run a backtest on (I use formulas such as =If(D2>C2,1,"") on a new column next to my combination of data to place a 1 in front of every combination that is not suitable to my backtest and then using the Data/Filter show every row which has the number 1 in front of it and tehn delete those rows)
6) Merge the columns again using & into a new column. (example, =A2 & B2 & C2 & D2 & E2 & F2 )
7) Run Data/ Remove Duplicates to remove all the duplicates of combined variables and again separate the data into each individual columns.
8) Introduce a new variable in metaeditor for each of your groups of codependent variables, each input of which will correspond to one of the combinations of the 5 or 6 variables in the excel sheet (For example, in my code, I named that variable AutoTrailVar as such:
input int AutoTrailVar = 1; whereas case of Autovariable = 1 would correspond to the combination of my 5 or 6 variables each having a specific input value and case = 2 would correspond to the 6 variables having another set of inputs.
9) to facilitate the metaeditor programing, I combined all the variations of the code in my excel (see column AE and how the "= G & H & I & ... has combined to write the code i would be cutting and pasting into my metaeditor below:
10) add a function to be read on the int Oninit() as shown below:
int OnInit()
{
//---
AdjustTrailParameters();
And the function of AdjustTrailParameters(); in my program's case is simply a combination of cases for my single variable which has been cut and pasted into metaeditor from my excel sheet as shown above:
void AdjustTrailParameters()
{
//---
switch(AutoTrailVar)
{
case 1: AutoTrail_H1_After_RR=0; AutoTrail_M30_After_RR=0; AutoTrail_M15_After_RR=0; AutoTrail_M5_After_RR=1; AutoTrail_M1_After_RR=3; break;
case 2: AutoTrail_H1_After_RR=0; AutoTrail_M30_After_RR=0; AutoTrail_M15_After_RR=0; AutoTrail_M5_After_RR=1; AutoTrail_M1_After_RR=5; break;
case 3: AutoTrail_H1_After_RR=0; AutoTrail_M30_After_RR=0; AutoTrail_M15_After_RR=0; AutoTrail_M5_After_RR=1; AutoTrail_M1_After_RR=6; break;
case 4: AutoTrail_H1_After_RR=0; AutoTrail_M30_After_RR=0; AutoTrail_M15_After_RR=0; AutoTrail_M5_After_RR=1; AutoTrail_M1_After_RR=7; break;
case 5: AutoTrail_H1_After_RR=0; AutoTrail_M30_After_RR=0; AutoTrail_M15_After_RR=0; AutoTrail_M5_After_RR=1; AutoTrail_M1_After_RR=8; break;
...
11) now when I run a backtest and use different variable input for my Single input "AutoTrailVar' (instead of 5 different inputs for each of my codependent variables), I will only have the combination of variables which result in a meaningful backtest outcome as preselected in my excel sheet without the use of Kill pass.
12) you can do the same for any number of codependent groups of variables within your program for which you'd like to filter out a number of passes as per the guidelines described above.
Hope that helps and good luck.
Mohammad Hossein Najarzadeh #: the optimizer calculates a zero result for the pass which perhaps (correct me if i'm wrong pls) will misguide the next generation of the fast genetic based method.
at the beginning of the optimization the terminal generates a list of passes (does it?)
and creates the generations of optimizations based the that list (if such a list exists)