Not for MT developers! What to replace INIT_PARAMETERS_INCORRECT with ? - page 3

 
Georgiy Merts:

What's that? By replacing the incorrects with the nearest corrections ??? I'm afraid it all depends on how we distribute those same incorrections. It's quite possible that the nearest corrections - will be away from the top.

And it will turn out that instead of wrong sets of parameters - we will have correct results - which also, in my opinion, should not be done - what do we find then? We'll get a maximum, and it will have an incorrect set of parameters ?

Honestly, I don't see a problem. However, my competence on the variant under discussion is zero.

 
fxsaber:

I think @Andrey Dik can help on these issues. But even constructive criticism of the regular GA didn't end well for him...

Banned, unfortunately. Sending rays of unbanning to the administration, well, how much longer can you?

 
Georgiy Merts:

How about writing a function that only outputs valid chains by number ?

The first thing that comes to mind is a table of 117649 values, and let genetics look for numbers in this table.

No, the table with valid chains would be much smaller, but even if there are 5000 of them, how can we write them and not get confused?

 
Сергей Таболин:

No, the table with the correct chains will be considerably smaller, but even if there are 5000 of them, how do you spell them out and not get confused?

To a file dump. Then look up the pass number and match it to what is in the file.

 
fxsaber:

Into the file reset. Then see the pass number and match it to what is in the file.

I meant how not to confuse, not to repeat, not to miss during the prescription process itself?

 
Сергей Таболин:

I meant how not to confuse, not to repeat, not to miss in the process of prescription itself?

input int i1 = 0; 
input int i2 = 0; 
input int i3 = 0; 

sinput int NumPass;

void OnTesterInit()
{
  int StopNumPass = 1;
  
  // Считали оптимизационные параметры входных
  // ...
  
  for (int _i1 = Start1; _i1 < Stop1; _i1 += Step1)
    for (int _i2 = Start2; _i2 < Stop2; _i2 += Step2)
      for (int _i3 = Start2; _i3 < Stop3; _i3 += Step3)
        if (CheckCorrect(_i1, _i2, _i3))
        {
          // записали проход в файл
          //...
          
          StopNumPass++; // см. ниже
        }
        
  // Сбросили оптимизацию входных и назначили NumPass от 1 до StopNumPass с шагом 1.
}


In this example, the result will strongly depend on the order in which the for loops are placed. All because of this peculiarity.

Forum on trading, automated trading systems and strategy testing

Not for MT Developers! What to replace INIT_PARAMETERS_INCORRECT with ?

fxsaber, 2018.07.10 16:27

Obviously if you trace a full enumeration of y = x^2. Then randomly shuffle the opimization rows and create a new set based on the shuffling. Then the GA will not find the vertex of the parabola.

 

Not more than a week ago I was banned for a similar thread for a moment and the thread/survey was ripped out as an unnecessary page with roots.

As for the question, I already wrote that it would be optimal to exclude all combinations that are forbidden, this can be optimally done by the developer, otherwise you need to make a script that runs through all combinations and saves only allowed combinations into a file, and already load that file for optimization using genetics.

 
I am inclined to conclude that the author's problem is in the architecture of his programme.
 
xFFFF:
I'm inclined to conclude that the author's problem is with the architecture of his program.

Thanks for your opinion, but there's no discussion here about the architecture of the programme. In case you haven't noticed...

 
fxsaber:

Obviously, if you trace a complete enumeration of y = x^2. Then randomly shuffle the opimization strings and create a new set based on the shuffling. The GA will not find the top of the parabola.

I have created a test Expert Advisor for the optimizer's mat mode

// #define TESTER_FILE // Советник будет работать не только на локальных Агентах, но и в Облаке.

#ifdef  TESTER_FILE
// Нужно компилировать (не запускать) советник, когда этот файл (с любым содержанием, хоть пустой) лежит в Песочнице.
// Иначе Тестер не будет видеть эти данные, даже если соответствующий файл с ними положить после компиляции на место.  
  #property tester_file __FILE__ 
  
  const int FileCommon = 0;
#else
  const int FileCommon = FILE_COMMON;
#endif // TESTER_FILE

sinput bool Rand = false;     // Вкл/выкл. перемешивание
sinput int NumPass = 10001;   // Количество проходов

// Фитнесс-функция
double Func( const double X )
{
//  return(X); // Проверка, что Агенты считывают нужные данные
  return(-X * X + 1); // Парабола с максимальным значением в единице - его и будем искать
}

// Меняет местами элементы массива
template <typename T>
void Swap( T &Array[], const uint Pos1, const uint Pos2 )
{
  const T Tmp = Array[Pos1];
  
  Array[Pos1] = Array[Pos2];
  Array[Pos2] = Tmp;
}

// Возвращает случайный индекс массива
uint GetRandPos( const uint Size )
{
  return(MathRand() * (Size - 1) / SHORT_MAX);
}

// Перемешивает элементы массива
template <typename T>
void Mixing( T &Array[], const uint AmountIterations )
{
  const int Size = ArraySize(Array);

  MathSrand((uint)TimeLocal()); // Повторные запуски Оптимизатор будет игнорировать - build 1881
  
  for (uint i = 0; i < AmountIterations; i++)
    Swap(Array, GetRandPos(Size), GetRandPos(Size));
}

// Вычисляет интервал оптимизации
void SetInterval( double &Array[], const double Begin, const double End, const uint Amount )
{
  if (Amount > 1)
  {
    const double Step = (Begin - End) / (Amount - 1);
    double Tmp = End;
    
    for (int i = ArrayResize(Array, Amount) - 1; i >= 0; i--, Tmp += Step)    
      Array[i] = NormalizeDouble(Tmp, 8);
  }  
}

#define  TOSTRING(A) #A

void OnTesterInit()
{
  ParameterSetRange(TOSTRING(NumPass), true, 0, 0, 1, NumPass - 1); // Задали Оптимизатору количество проходов = NumPass
  
  double Array[];
  
  SetInterval(Array, -1, 1, NumPass); // Выстроили значения интервала по порядку
  
  if (Rand)
    Mixing(Array, NumPass * 10); // Перемешали все в интервале
    
//  ArrayPrint(Array); // Проверка, что Агенты считывают нужные данные
    
  FileSave(__FILE__, Array, FileCommon); // Записали файл-интервал. А ведь так можно передать в Облако хоть содержимое всей Песочницы + полный стейтмент.
}

void OnTesterDeinit()
{
  if (FileCommon)
    FileDelete(__FILE__, FileCommon); // Удалили файл-интервал
  
  ChartClose(); // Закрыли чарт Frame-выполнения советника
}

double OnTester()
{
  double Array[];
  
  // Считали точку из интервала и вернули значение фитнесс-функции в ней
  return((FileLoad(__FILE__, Array, FileCommon) != -1) ? Func(Array[NumPass]): 0); // В режиме не-tester_file FileLoad будет выдавать ошибку, если два Агента одновременно обратятся.
}


I markedin red the vulnerabilities, weaknesses and current errors of MT5 that appeared while writing the example.