Error #1 when modifying orders - page 5

 
borilunad:

Victor, why did you modify the SL and TP in the pending positions? In general, it makes sense to set the SL only after opening a position, and the TP after the transfer of the SL to the B/S! So why bother the server so much for nothing and why do you have to go through all this trouble?!

We must minimize and simplify the code, to make it work fast and clear, and then it will be easier to tweak it because of the vagaries of the market! Give careful consideration to all the nuances of the market realities!

I also put a stop loss on the pending orders, just in case the connection is interrupted or something else prevents me from setting a more accurate stop (from the system's point of view) after the order triggers.

If everything is OK, then after the order triggers, I put a stop at the right level.

 
Stells:

I also put a stop loss on the pending orders immediately, in case the connection is interrupted or something else prevents me from setting a more correct stop, from the system's point of view, after the order has been triggered.

If everything is OK, then after the order triggers, I put a stop at the right level.

In this you are right, if according to the TS you set your SL close to the opening price! But to modify the opening price, SL and TP several times is not reasonable, it spends so much effort and complicates the code, it is not worth the effort!
 

Victor, if you need it that badly, you can make it easier! Check the opening price only, and mark SL and TP in the same way as you do when you set a pending order with SL and TP!

That means for the SL write Ask-SL or Bid+SL, and for TP, respectivelyAsk+TP or Bid-TP! Try it, it should work fine! So nothing is impossible! :)

 
borilunad:

Do you want the Modify() function?

I wouldn't say no. And I'm even waiting somewhere... Since last night.

keekkenen:
the code seems fine... but on real (not demo) it works ?
Yes. In many EAs where I didn't have to mod 3 input parameters at once it works. Note that I downloaded a variant for the tester and there is also a variant for the real world.

borilunad:

Victor, why did you start modifying SL and TP in the pending orders? In general, it makes sense to set the SL only after opening a position and TP after the SL is moved to B/B! So why bother the server so much for nothing and why do you have to go through all this trouble?!

We must minimize and simplify the code, to make it work fast and clear, and then it will be easier to tweak it because of the vagaries of the market! Think carefully about all the nuances related to market realities!

Boris, if according to the documentation 3 parameters can be modified simultaneously, why not use it? After all, it's convenient! I am thinking of changing the stop and take options. However, I want this option to work properly, if this feature is specified in the documentation. If it is not, we must write that it is not possible. Then the question will disappear by itself.
 
borilunad:
In this you are right, if according to TS you put your SL close to the opening price! But to modify the opening price, SL and TP several times is unreasonable to waste so much effort and complicate the code, it's not worth the effort!

Boris, who says I'm pounding the server too often? I wasn't talking about the trading system. There are different variations. Sometimes only STOP is moved, sometimes STOP and TAKE are moved too. These are different variants. But in this case, in my case, the stops are moved every several hours on the average. Or once every hour. Is that a lot of complicates code?

On the contrary, the code becomes... simpler. You call a modification function... put 3 parameters in it and modify it... Ideally, not counting any glitches in the terminal.

But if it doesn't. Then we will have to modify the OPEN PRICE, then the conditions are fulfilled... the STOP price, and after some conditions are met or some time has passed, we will have to modify the TAKE price. Is this like Simplifying code?

 
hoz:

I won't say no. And I'm even waiting somewhere... So since last night.

Yes. In many EAs where I didn't have to modify 3 input parameters at once it works. Note that I have discounted the version for the tester, and there are also for the real.

Boris, if according to the documentation 3 parameters can be modified simultaneously, why not use it? After all, it's convenient! I am thinking of changing the stop and take options. However, I want this option to work properly, if this feature is specified in the documentation. If it is not, we must write that it is not possible. Then the question will disappear by itself.

Victor, check out my next post where I gave you the idea to check only the opening price, and re-set the SL and TP from the price without any fuss!

And I'll post the function now! I also "waited" somewhere that you responded yesterday! We'll be simpler.

#include <stderror.mqh>//штатные инклюдники, чтобы 
#include <stdlib.mqh>  //вызывался ErrorDescription()



//------------------------/  Modify Order  \------------------------\\
void ModifyOrder(int ticket,double price,double stoploss,double takeprofit,datetime e,color arrow_color)
{
  int ModifyCnt = 0, err;
  while(ModifyCnt < 3) {
    if(OrderModify(ticket,NormalizeDouble(price,Digits),NormalizeDouble(stoploss,Digits),
    NormalizeDouble(takeprofit,Digits),0,arrow_color))
    ModifyCnt = 3;
    else err = GetLastError();
    if(err > 0) { 
      Print(ModifyCnt," #",ticket," Error modifing order: (", err , ") " , ErrorDescription(err));
      Sleep(5000); RefreshRates(); ModifyCnt++;
} } }

Any questions, ask, do not wait until tomorrow! ;)

Function is universal, serves for any modifications with pending and open positions! Good luck!

Just now, like yesterday, going to lunch! All the best!

 
borilunad:

I'll post the function now! I was waiting somewhere for you to respond yesterday, too! Let's keep it simple.

If you have any questions, don't wait until tomorrow! ;)

Function is universal, serves for any modifications with pending and open positions! Good luck!

What about the stop and frizzle checks? Or it's not needed nowadays? :) Concerning your function code, I agree. It's simple and straightforward. But the checks... they're not there. Why not?

I'm going to dinner:

Just now, like yesterday, going to lunch! Everything!

Who's having lunch and who's already having dinner at this time...
 
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 like this:

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?

Remove else.
 
hoz:

Boris, what about the stopplevel and frizzlevel checks. Or is that unnecessary these days? :) Regarding your function code... I agree. It's simple and straightforward. But the checks... they're not there. Why not?

Who's having lunch and who's already having dinner at this time...

All checks are done before the loop, which has conditions relating to each type and a call to this function, which only checks for errors in Modify():

            ModifyOrder(OrderTicket(),OOP,SL,0,0,clrBlue); return(0);

Anything else, ask, but I'm off to dinner now. ;)

 
How did you vote?
Reason: