[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 556

 
Only I need a condition not (Ask<tmp || Ask>tmp) but just a trivial one ( Ask<=tmp). That is, as soon as a single tick appears in the other direction... and exactly with a loop)... I know, the truth is somewhere nearby))).
 
maryan.dirtyn >>:
в вашем варианте работает, и ЕТО уже большой прорыв ). только мне нужно условие не (Ask<tmp || Ask>tmp), а просто банально (Ask<=tmp). тоесть как только появиться хоть один тик в другую сторону... и именно с циклом).. я знаю, истина где то рядом))). хотя б на реале работало, бог с ним, с тестером то.

Well the same - same logic. Before the loop, we bring the variable to such a state, in which the loop condition will be true. Then at each loop iteration we refresh data using RefreshRates() and check if the quote is fresh, then perform some action and forcefully break the loop. If we want the code, which lies below the loop, to be executed, then we break it with break command. If we do not want it to be executed, we interrupt the int start() function of the EA with the command return(0)
 

I understand the logic of how to do it... I don't understand why none of the designs work, a few more have fallen into the abyss of trying.

double tmp=Ask; while(Ask<=tmp) tmp=Ask; Print("Заработало");
 double tmp=0;  while(Ask<=tmp || tmp==0) { RefreshRates(); if(Ask>tmp) break;} Print("Заработало");
 
maryan.dirtyn >>:

я логику понимаю, как ето сделать.. я не понимаю почему не работает ни одна конструкция, еще несколько канули в бездну перебора вариантов


You have to close your eyes and imagine what happens in each iteration of the cycle.

Your first option:

The tempo is equal to asc. The equality condition is satisfied, so the loop enters an almost infinite number of iterations. For even if a new quote arrives, it is not certain that it will break the cycle's truth condition. Couple or three in a row of falling ascs and we may wait until the cycle is almost infinite...

 

When MQL4 textbook came out, I thumbed through it and did not go back - I did not like that the author of this book put while() loop everywhere he went. It left a mark on many people who tried to learn MQL from this book.

Tell me your Expert Advisor has such a terrible task that you can't do without this loop? Well, you see how easy it is to run this loop for an infinite number of iterations, just losing control. Can't you do without the for() loop in your case? Or by writing a separate simple function...?

 

The main thing is that it works... I'm sick of buying a falling knife. I need any, even the most elegant, solution to the problem:

double tmp=Ask; 
                 while(Ask<=tmp) tmp=Ask; 
                                              Print("Заработало");
 
drknn >>:

Честно-говоря, когда вышел учебник по MQL4, я его пролистал и больше к нему не возвращался - мне не понравилось, что автор этого сочинения суёт там цикл while() везде где ни попадя. Это наложило отпечаток на многих, кто пытался освоить MQL по данной книге.

Вот скажите, что у Ваего советника, такая жуткая задача, что нельзя обойтись без этого цикла? Ну ведь сами видите, насколько легко запустить этот цикл в бескоенчное число итераций, просто потеряв контроль. Циклом for() в Вашем случае обойтись нельзя? Ну или написанием каой-то отдельной простенькой функции?...

I'm not new to mql. I've mastered it for two years now. yes, i need it whereas. i go back to the tutorial from time to time to see if i yawned)... you don't see a rabbit? but i do. it's not that simple.
 
Sorry to interfere, but this way the loop will be infinite. tmp should be made static with an initial value knowingly higher than Ask. Or =0 if we use the proposed construction with OR. Otherwise, Ask will always be = tmp.
 
Svinozavr >>:
Извините, что вмешиваюсь, но в таком виде цикл и будет бесконечным. tmp нужно сделать static с присвоением ей началного значения заведомо большего Ask. Или =0, если использовать предложенную конструкцию с ИЛИ. А так Ask всегда будет = tmp.
The problem is simple... while the price is going down, do not buy until the tick is to the other side... and the code must be looped in one place, while it is going down, do not touch anything...
 

It's just not clear why there is a cycle here. Check at every price tick and act on the realities.