What's more specific? Can't you think of a counter-example to your implementation? Explain what arrays and structures are?
I'm afraid to even guess what will happen if you need to get not only the number of the order, but also the price, for example.
All in all, some kind of ignorance. And it is not that of a beginner, and therefore inexcusable. Shame on the resource if somebody from outside would cite this thread as an example of "look at the level of programmers in MQL!
And how do you define the level? I'm a beginner on many issues too, but Peter seems to be a militant ignoramus. And not only in Tester or OOP. He doesn't have a problem with MetaEditor. Maybe he uses it seldom? And where is even a single code in the library? Or in products? (
/+------------------------------------------------------------------+
//| Magic.mq5 |//| Peter Konow |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Peter Konow"#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+string All_magics;
int order_number;
int Random_orders_of_strategy;
//+------------------------------------------------------------------+void Save_magic(int magic)
{
order_number++;
//---------------------------------//Записываем каждый магик вместе с порядковым номером ордера.//---------------------------------
All_magics += "_" + (string)order_number + "_" + (string)magic; // Тут как бы не рационально особенно для скорости - в данном случае будет происходить поочередное сложение т.е. сперва стрин увеличиться на один знак и ему выделеиться дополнительно 1 чарт, потом увоичиться на количество символов в (string)order_number.... и каждый раз будет происходить выделение памяти... //---------------------------------
}
//+------------------------------------------------------------------+void Trading()
{
Random_orders_of_strategy = MathRand(); ///Всеже проще рандом не вызывать при тестах на скорость - т.к. хз сколь уйдет времени на эту функцию//----------------------------------------//Имитируем открытие неопределенного количества ордеров стратегии.//----------------------------------------for(int a1 = 0; a1 < Random_orders_of_strategy; a1++)
{
int this_magic = MathRand();
//----------------------------
Save_magic(this_magic);
//----------------------------
}
//----------------------------------------
}
//+------------------------------------------------------------------+int Get_magic(int deal_number)
{
//--------------------------------------------//Получаем начало строки магика.//--------------------------------------------int Magic_position_start = StringFind(All_magics,"_" + (string)deal_number + "_",0) + 3; // поиск происходит слушающим образом... наш string разбирается на масив чартов и мы начинаем искать среди них номер чарта равный номеру символа "_" путем перебора, если произошло совпадение то будем сравнивать второй символ... даже банально исключив последний + "_" скорость возрастет//--------------------------------------------//Получаем конец строки магика.//--------------------------------------------int Magic_position_end = StringFind(All_magics,"_" + (string)(deal_number + 1) + "_",0); //тут по идее снова начинается поиск и он уже идет с самого начала снова не знаю зачем искать еще раз, надо хотябы поиск начинать с тагоже места где нашли начало маджика чтоли... и искать просто подчеркивание... //--------------------------------------------//Получаем количество цифр из которых состоит магик.//--------------------------------------------int Magic_lenght = Magic_position_end - Magic_position_start;
//--------------------------------------------//Извлекаем магик из общей строки.//--------------------------------------------string Magic = StringSubstr(All_magics,Magic_position_start,Magic_lenght);
//--------------------------------------------//Возвращаем цифровое значение магика.//--------------------------------------------return((int)Magic);
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
Trading();
//--------------------------ulong t1 = GetMicrosecondCount();
Get_magic(1); // Мы же на скорость проверяем так что давайте исполняемые функции брать в цикл с повтором в 10 000 раз... хотябы лучше с изменяющими входными параметрамиulong t2 = GetMicrosecondCount();
//--------------------------Print("Время исполнения функции Get_magic() при количестве ордеров ",Random_orders_of_strategy," равно ",t2 - t1);
//--------------------------Print("Random_orders_of_strategy ",Random_orders_of_strategy);
Print("magic 1: ",Get_magic(1)," magic 2: ",Get_magic(2)," magic 3: ",Get_magic(3));
}
//+------------------------------------------------------------------+
And how do you determine the level? I am also a novice on many issues, but Peter seems to be a militant ignoramus.
And I am new to many issues. And when my militant ignorance gets dunked in a vat of shit, I don't pretend it didn't happen. I'm thankful for the sobering lesson.
There is never any shame in being a novice or not knowing something. In this case, however, pride of ignorance is present, and it's also off the charts.
The only benefit - it turns out one of the best motivators to create a Blacklist on the resource.
Reg Konow, your level of knowledge of "data structures" is 0.
1. Your code is not working. Wrong "_index_magic" pattern. Possible solution is "|index_magic".
2. Your algorithm has speed O(n) with as many as three passes of string valueAll_magics
3. Your performance measurement is completely incorrect:
- there is no average result in the series - no series with search for the last index values
Instead of writing nonsense - please study something on the subject, e.g.https://habrahabr.ru/post/310794/. And then learn how to apply CArrayList from <Generic\ArrayList.mqh>. Good luck.
What's more specific? Can't you think of a counter-example to your implementation? Explain what arrays and structures are?
I'm afraid to even guess what will happen if you need to get not only the number of the order, but also the price, for example.
All in all, some kind of ignorance. And it is not that of a beginner, and therefore inexcusable. Shame on the resource if somebody from outside would cite this thread as an example of "look at the level of programmers in MQL!
And how do you define the level?
I'm a beginner on many issues too, but Peter seems to be a militant ignoramus.
And not only in Tester or OOP.
He doesn't have a problem with MetaEditor.
Maybe he uses it seldom?
And where is even a single code in the library? Or in products?
(
You provide your solution. Otherwise it's just empty words. Same as before.
Are you ready?
Forum on trading, automated trading systems and trading strategy testing
Algorithms, solution methods, comparing their performance
fxsaber, 2017.12.10 16:12
Almost everyone here is willing to do if you enter read-only mode for a month afterwards.
Are you ready?
Here is the practical proof:
I haven't even seen such gloom in the "newbie questions" thread. Guys, this is just plain creepy! What is there to comment on?
s. Well, why do you write Get_magic(1), write Get_magic(23999).
And how do you determine the level?
I am also a novice on many issues, but Peter seems to be a militant ignoramus.
And I am new to many issues. And when my militant ignorance gets dunked in a vat of shit, I don't pretend it didn't happen. I'm thankful for the sobering lesson.
There is never any shame in being a novice or not knowing something. In this case, however, pride of ignorance is present, and it's also off the charts.
The only benefit - it turns out one of the best motivators to create a Blacklist on the resource.
I haven't even seen this kind of gloom even in the "newbie questions" thread. Guys, that's just crazy! What is there to comment on?
S.s. No, well, why do you write Get_magic(1), write Get_magic(23999).
Does the solution work?
Does the solution work?
No, it doesn't, because StringFind can find the medjik number instead of the transaction number.
No, it doesn't work, because StringFind can find the median number instead of the transaction number.
StringFind first finds the trade number ("_" + trade number + "_").
Then we add 3 and get the start of the megic.
Then StringFind searches for the start of the next trade.
Then it subtracts the beginning of the next trade from the beginning of the megic.
Then StringSubstr gets the string of the megic.
Then we convert it to int and return it.
What doesn't work here?
What does not work here?
Forum on trading, automated trading systems and trading strategy testing
Algorithms, Decision Methods, Comparison of Their Performance
Sergey Dzyublik, 2017.12.10 16:10
Reg Konow, your level of knowledge of "data structures" is 0.
1. Your code is not working.
Wrong "_index_magic" pattern. Possible solution is "|index_magic".
2. Your algorithm has speed O(n) with as many as three passes of string valueAll_magics
3. Your performance measurement is completely incorrect:
- there is no average result in the series
- no series with search for the last index values
Instead of writing nonsense - please study something on the subject, e.g.https://habrahabr.ru/post/310794/.
And then learn how to apply CArrayList from <Generic\ArrayList.mqh>.
Good luck.