Error #1 when modifying orders

 

How do I get rid of this fucking error? I'm sick of it. I'm checking every input parameter of the function. For me, at the moment, it's like this:

if (OrderOpenPrice() != ND (fd_MurreyLevelsValue[11]))
   New_OOP = ND (fd_MurreyLevelsValue[11]);
else New_OOP = OrderOpenPrice();
if (OrderStopLoss() != ND (fd_MurreyLevelsValue[12]))
   New_SL = ND (fd_MurreyLevelsValue[12]);
else New_SL = OrderStopLoss();
if (OrderTakeProfit() != ND (fd_MurreyLevelsValue[2]))
   New_TP = ND (fd_MurreyLevelsValue[2]);
else New_TP = OrderTakeProfit();

That is, if the parameter hasn't been changed, there's no need to change it. I haven't done that before, but I decided to...

Then the parameters are passed to the order modification method as follows:

 if (!fOrderModify (Ticket,  New_OOP, New_SL, New_TP))
{
   if (_LastError != 0)
     WriteLog (StringConcatenate (__FUNCTION__, ". В строке ", __LINE__, " ", CErrs.ErrorToString (_LastError)),
                     CLogs.GetNeedLogs(), CLogs.GetPrintUP(), CLogs.GetCommentUP());
}

Nw output in the log:

modify #2  sell limit 0.10 EURUSD at 1.34048 sl: 1.34125 tp: 1.33362 ok
OrderModify error 1

So, the journal notifies us, like modification: OK, but then an error. None of the parameters has changed.

The order is pending. So we may change open, stop and take price. And this, as I understand it, did not contradict the documentation.

Who has encountered something like this? How to solve it?

 
hoz:

How do I get rid of this fucking error? I'm sick of it. I'm checking every input parameter of the function. For me, at the moment, it's like this:

That is, if the parameter hasn't been changed, there's no need to change it. I haven't done that before, but I decided to...

Then the parameters are passed to the order modification method as follows:

Nw output in the log:

So, the journal notifies us, like modification: OK, but then an error. None of the parameters has changed.

The order is pending. So we may change open, stop and take price. And this, as I understand it, did not contradict the documentation.

Who has encountered something like this? How to solve it?

You are mishandling the error code, forgetting that the error code is already overridden after your numerous functions.

So when an error occurs, you need to save the error code into a local variable and print it out from there, after the mass of your subsequent calls.

 
Renat:

You're mishandling the error code, forgetting that the error code is already overridden after your numerous functions.

Therefore, when an error occurs, its code must be saved in a local variable, and only then, after the mass of your subsequent calls, print it out.

Why don't you create an error array as well? It is written in black and white in the documentation that the _LastError variable stores the number of the last error. And it is reset by ResetLastError() function. If there are no more errors between calls of _LastError, _LastError stores the value of the last error. There were no more errors in my code. Well, that's not the issue.

Besides, it is not very logical to create variables for errors in each method and then print these variables into Expert Advisors.

After all, if there is a variable to collect errors, why make new ones?

 

evillive, what do you mean there are no checks? I wrote above:

if (OrderOpenPrice() != ND (fd_MurreyLevelsValue[11]))    \\ Если текущая цена не равна новой.. из массива, то..
   New_OOP = ND (fd_MurreyLevelsValue[11]);               \\.. новая цена равна этому новому значению цены из массива( расчитанного ).
else New_OOP = OrderOpenPrice();                          \\ Иначе новая цена равно текущей цене выбранного ордера. Т.е. не изменяется.
if (OrderStopLoss() != ND (fd_MurreyLevelsValue[12]))
   New_SL = ND (fd_MurreyLevelsValue[12]);
else New_SL = OrderStopLoss();
if (OrderTakeProfit() != ND (fd_MurreyLevelsValue[2]))
   New_TP = ND (fd_MurreyLevelsValue[2]);
else New_TP = OrderTakeProfit();

I even gave a comment for the first one. Although everything is elementary there.

How else can you check here?

 
I do a double check that it's not equal and directed where you expect!
 
evillive:
I realised, that's why I cleaned up)))
You're being rude! ;)
 
borilunad:
I do double check that it is not equal and directed where you expect!

Boris, what do you mean by that? Because I have it clearly written that if the price is not so... otherwise... current... What's the point? You can check it 20 times... :) It doesn't make sense. I've been struggling with this code for the second day now. I've never encountered such a bug before. Now I have faced it. I have already written and tested all these methods many times. I have faced a problem here.

The thing is, I'm more of a fan of slightly different tactics. But writing the latest Owls, came across this glitch. That's myself do not know where to dig, because pristrintovav all code lengthwise and otherwise I have no more thoughts. That's why the OrderModify() function is built-in. And I don't know its implementation.

 
hoz:

evillive, what do you mean there are no checks? I wrote above:

I even gave a comment for the first one. Although everything is elementary there.

How else can you check here?

Victor, after checking, the new value is assigned or not... You have to check.

if (OrderOpenPrice() != ND (fd_MurreyLevelsValue[11])  // Если текущая цена не равна новой.. из массива
 || OrderStopLoss() != ND (fd_MurreyLevelsValue[12])   // или 
 || OrderTakeProfit() != ND (fd_MurreyLevelsValue[2])) // или
  // если одно из условий выполнено пойдём в модифай... 
 
AlexeyVik:

Victor, after checking the new value is assigned or not... You have to check

Alexey, and where do you have a check to make sure that the value of the functions being passed is unchanged? I have already taken this into account above. And the need for modification in general is done at the start. There are levels there, if the indicator reports that the level has changed, let's move on...

 
hoz:

Boris, what do you mean by that? Because I have it clearly written that if the price is not so... otherwise... current... What's the point? You can check it 20 times... :) It doesn't make sense. I've been struggling with this code for the second day now. I've never encountered such a bug before. Now I have faced it. I have already written and tested all these methods many times. I have faced a problem here.

The thing is, I'm more of a fan of slightly different tactics. But writing the latest Owls, came across this glitch. That's myself do not know where to dig, because pristrintovav all code lengthwise and otherwise I have no more thoughts. That's why the OrderModify() function is built-in. And I don't know its implementation...

Victor, you Renat, in general, correctly noted, Alexey showed the necessary last check, and earlier, check all the necessary checks for each parameter with all the nuances, to avoid ambiguity of meaning and without missing any condition!
 
hoz:

evillive, what do you mean there are no checks? I wrote above:

if (OrderOpenPrice() != ND (fd_MurreyLevelsValue[11]))    \\ Если текущая цена не равна новой.. из массива, то..
   New_OOP = ND (fd_MurreyLevelsValue[11]);               \\.. новая цена равна этому новому значению цены из массива( расчитанного ).
else New_OOP = OrderOpenPrice();                          \\ Иначе новая цена равно текущей цене выбранного ордера. Т.е. не изменяется.
if (OrderStopLoss() != ND (fd_MurreyLevelsValue[12]))
   New_SL = ND (fd_MurreyLevelsValue[12]);
else New_SL = OrderStopLoss();
if (OrderTakeProfit() != ND (fd_MurreyLevelsValue[2]))
   New_TP = ND (fd_MurreyLevelsValue[2]);
else New_TP = OrderTakeProfit();

I even gave a comment for the first one. Although everything is elementary there.

How else can you check here?

We also need to check that if none of 3 parameters has not changed, then OrderModify should not be touched. Or rather, if at least one of these parameters has changed, only then go to OrderModify.
Reason: