Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 98

 
Andrey Sokolov:
When we have both Buy and Sell sections of the code, then, after the pending order triggers, its stop will be corrected in any price direction for some reason. And when there is only a Buy or Sell part of the code, the stop is corrected as intended, only when the price moves away from it.

So tidy up the code, there are a lot of errors there. For example, for any action with an order, it must first be selected byOrderSelect() function, this condition is not fulfilled everywhere in your code. Then, when modifying an order, those parameters that remain unchanged, should be passed in their original form, and not zeroed out.

That is, instead ofOrderModify(ticket, price, sl,0,0, Blue), we needOrderModify(ticket, price, sl,OrderTakeProfit(),OrderExpiration(), Blue).

We should not hope that the ticket is stored in memory forever, it's not true, especially when several orders are opened, and their tickets are written in the same variable. And then try to modify or delete the order by an unknown ticket.

 
Andrey Sokolov:
When there are both parts of the code, both for buy and for sell, then after the pending order triggers, its stop is corrected in any price direction for some reason. And when there is only a BUY or SELL part of the code, the stop is corrected as intended, only when the price moves away from it.
First, make different variables for buy and sell tickets
 
Vitalie Postolache:

For example, for any action on an order, it must first be selected withOrderSelect(), a condition that is not met everywhere.

This is how it is selected, the function at the end. Or what is wrong?
 
Vitalie Postolache:

Then, when modifying the order, those parameters that remain unchanged must be passed in their original form, not zeroed out.

That is, instead ofOrderModify(ticket, price, sl,0,0, Blue), you shouldOrderModify(ticket, price, sl,OrderTakeProfit(),OrderExpiration(), Blue).

Profit and time of expiration are missing there, therefore it's zero. Is it incorrect?
 
Sergey Gritsay:
First, make different variables for buy and sell tickets
Vitalie Postolache:

You can't hope to keep a ticket in memory forever, it's not true, especially when multiple orders are opened and their tickets are written to the same variable. And then trying to modify or delete an order by an unknown ticket.

Thank you.

That was indeed the problem. But I did so even before I asked here, apparently I had to go to sleep.

 

i'm new to posting, i've been working on this for a while now.

i have a good impression that it works well but i have a problem with drawdown, what i should do if i want to drawdown less.

i have a sell trade open on the screenshot.

 
Denizrip:

i'm new to posting, i've been working on this for a while now.

i have a good impression that it works well but i have a drawdown, what i should do if i want to drawdown less.

i have a sell trade open on the screenshot.

You should have opened Buy instead of Sell and at 1.0620 Sell, we would not have had slippage.
 
Denizrip:

i'm new to posting, i've been working on this for a while now.

i have a good impression that it works well but i have a drawdown, what i should do if i want to drawdown less.

i have a sell trade opened on the screenshot.

Build a time machine, urgently. Come back a little earlier than the time of sale, smack yourself and instead of selling you buy :)

But seriously, the "price went up" much earlier than the time indicated by the arrow in the picture. So, the position should have been reversed, instead of waiting till the price went further up.

Or, to average where the last arrow is, if the deposit is enough. That's if the stoploss disgusts you, but otherwise - stoploss rules.

 
Denizrip:

i'm new to posting, i've been working on this for a while now.

i have a good impression that it works well but i have a drawdown, what i should do if i want to drawdown less.

i have a sell trade opened on the screenshot.

2 variants:

put a stop before it turns into a trawl

or catch a loss and enjoy the moment

 

Vitaly Muzichenko:

.... and someone for trading, so you can use more than one cycle.

Thank you.

Reason: