I mean, I do OrderSelect once and then again from the function... That's a hell of a thing...
You have selected an order on a ticket
You go to the function that checks the number of orders. If there is more than one order, all the available orders are selected one by one in the cycle
When you return from the function, the order selected will be the one which was last in the list of orders in the client terminal (it will not necessarily be the order you selected in point 1).
Then you check the time of closing of a new order, and you are trying to close the one which was supposedly selected by the ticket, but its selection has been already lost.
Simple logic...
Watch the sequence of operations you are making.
Obviously, you must first check the quantity, then select the required order, and then perform the necessary operations on it.
if there are possible closures/deletions during "revision", it is better to look in the opposite direction. From OrdersTotal()-1 to 0 inclusive.
Otherwise you might get in trouble :-)
I almost discovered my personal grail in this way once :-)
And the removal of old orders from the "depths of time" to the present (once in a while, not all of them) raised the tester profitability to the heavens :-)
You have gone into the function to check the number of orders. If there is more than one order, all of the available orders will be selected one by one to be counted in the cycle
When you return from the function, the order selected will be the one which was last in the list of orders in the client terminal (it does not necessarily have to be the order you selected in point 1).
Then you check the time of closing of a new order, and you are trying to close the one which was supposedly selected by the ticket, but its selection has been already lost.
Simple logic...
Watch the sequence of operations you are making.
It is obvious that you must first check the quantity, then select the right order, and then perform the necessary operations on it
for example, i found out that the minimum lot is 0.01.
how do i deduce that the number of decimal places is 2? to normalise the order volume to two decimal places later.
Try this one.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 16.05.2008 |//| Описание : Возвращает нормализованное значение торгуемого лота. |//+----------------------------------------------------------------------------+//| Параметры: |//| lo - нормализуемое значение лота. |//| ro - способ округления ( False - в меньшую, |//| True - в большую сторону) |//| sy - наименование инструмента ("" или NULL - текущий символ) |//+----------------------------------------------------------------------------+double NormalizeLot(double lo, bool ro=False, string sy="") {
double l, k;
if (sy=="" || sy=="0") sy=Symbol();
double ls=MarketInfo(sy, MODE_LOTSTEP);
double ml=MarketInfo(sy, MODE_MINLOT);
double mx=MarketInfo(sy, MODE_MAXLOT);
if (ml==0) ml=0.1;
if (mx==0) mx=100;
if (ls>0) k=1/ls; else k=1/ml;
if (ro) l=MathCeil(lo*k)/k; else l=MathFloor(lo*k)/k;
if (l<ml) l=ml;
if (l>mx) l=mx;
return(l);
}
Все продукты Маркета перед публикацией проходят обязательную предварительную проверку, так как небольшая ошибка в логике советника или индикатора может привести к убыткам на торговом счете. Именно поэтому нами разработана серия базовых проверок, призванных обеспечить необходимый уровень качества продуктов Маркета. Если в процессе проверки...
multiplicator: I see that the terminal normalises the order to the required number of decimal places when I open it. Maybe there is no need to normalize anything?
multiplicator: I see that the terminal normalises the order to the required number of decimal places when it opens. Maybe you don't need to normalize anything?
If you want to get error after error, do not normalise.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
There's something really wrong, though...
I mean, I do OrderSelect once and then again from the function... That's a hell of a thing...
Simple logic...
Watch the sequence of operations you are making.
Obviously, you must first check the quantity, then select the required order, and then perform the necessary operations on it.
in which direction do you view the order array?
if there are possible closures/deletions during "revision", it is better to look in the opposite direction. From OrdersTotal()-1 to 0 inclusive.
Otherwise you might get in trouble :-)
I almost discovered my personal grail in this way once :-)
And the removal of old orders from the "depths of time" to the present (once in a while, not all of them) raised the tester profitability to the heavens :-)
Simple logic...
Watch the sequence of operations you are making.
It is obvious that you must first check the quantity, then select the right order, and then perform the necessary operations on it
I have done it this way:
Just put order counting first, and then everything else.
Thank you Artem. I owe the grail to it. That was the mistake that was killing me...
How do I calculate the number of decimal places?
for example, i found out that the minimum lot is 0.01.
how do i deduce that the number of decimal places is 2?
to normalise the order volume to two decimal places.
How do I calculate the number of decimal places?
for example, i found out that the minimum lot is 0.01.
how do i deduce that the number of decimal places is 2?
to normalise the order volume to two decimal places later.
Try this one.
Try this one.
Why offer such old stuff?
How to calculate the number of decimal places?
For example, I have learned that the minimum lot is 0.01.
How can I find out that the number of decimal places is 2?
Then normalize the order volume to two decimal places.
Here's a ready-made function in the article.
All that remains is to add an action depending on the result returned by this function.
I put a lot like this
and the trade opens with a volume of 1.11.
So maybe you don't need to normalize anything?
I see that the terminal normalises the order to the required number of decimal places when I open it.
Maybe there is no need to normalize anything?
If the editor does the same - no need.
I see that the terminal normalises the order to the required number of decimal places when it opens.
Maybe you don't need to normalize anything?
If you want to get error after error, do not normalise.
If you want to subsequently get error after error, don't normalise.