[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 250

 
how to close an order partially? just change the volume of the trade with OrderModify?
 
artmedia70:

And think about the function code? Find four differences :) :




found the .... distinction...))))) uh-huh...I just dug into a programming textbook and my head's not cooked))
 
eddy:
how do I close an order partially? just change the volume of the trade with OrderModify?
No. Close the position with a smaller lot.
 
eddy:
how do I close the order partially? just change the volume of the trade with OrderModify?

Open the opposite order with a smaller lot. The difference is the remainder, which should continue to exist.

Close the opposite lot and part of the existing lot with OrderCloseBy().


 
coronel:

Open the opposite order with a smaller lot. The difference is the remainder, which should continue to exist.

Close the opposite lot and part of the existing lot with OrderCloseBy().

This trick won't work in Five. Don't forget about requotes and slippages too...
 
artmedia70:
This kind of trick will not work at Fiver. Don't forget about requotes and slippages too...

I'm sorry, which five? )) We are on MQL4.

I do not take into accountrequotes and slippages as a natural factor. The matter of fact does not change.

 
coronel:

I'm sorry, which five? )) We are on MQL4.

I do not take into account requotes and slippages as a natural factor. The essence does not change.

Do what you want - your choice to do two transactions instead of one.
 
artmedia70:
Do what you want - your choice to do two operations instead of one.
"Two surgeries instead of one" - more details, please. Might be helpful.
 
coronel:
"Two operations instead of one" - more details, please. It may prove useful.

To partially close a position with 1.0 lot, you can make one transaction, closing it with a smaller lot, for example 0.5.

Standard function:

__________________________________________________________________________________________________

bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE )

To close the position. Returns TRUE on successful completion of the function. Returns FALSE if the function fails. To get information about the error, call the GetLastError() function.
Parameters:
ticket - Unique serial number of the order.
lots - Number of lots to close.
price - The closing price.
slippage - The value of the maximum slippage in pips.
Color - Colour of the closing arrow on the chart. If the parameter is absent or its value is CLR_NONE, the arrow is not shown on the chart.

__________________________________________________________________________________________________

But you propose to make two operations:
1. open the opposite position with a smaller lot;

2. Close them counterclockwise, so that the position whose lot was bigger is left.

__________________________________________________________________________________________________

bool OrderCloseBy( int ticket, int opposite, color Color=CLR_NONE)

Closes one open position with another position opened on the same instrument, but in the opposite direction. Returns TRUE on successful completion of the function. Returns FALSE if the function fails. To get information about the error, call the GetLastError() function.
Parameters:
ticket - Unique serial number of the order to be closed.
opposite - The unique sequence number of the opposite order.
Color - Colour of the closing arrow on the chart. If this parameter is missing or its value is CLR_NONE, the arrow is not shown on the chart.

_________________________________________________________________________________________________

Accordingly, the number of adverse factors doubles per position.

Why?

 
artmedia70:

For partial closing of a position with 1.0 lot you can make one transaction, closing it with a smaller lot, for example 0.5.

Standard function:

__________________________________________________________________________________________________

bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE )

Closing the position. Returns TRUE on successful completion of the function. Returns FALSE if the function fails. To get information about the error, call the GetLastError() function.
Parameters:
ticket - Unique serial number of the order.
lots - Number of lots to close.
price - The closing price.
slippage - The value of the maximum slippage in pips.
Color - Colour of the closing arrow on the chart. If the parameter is absent or its value is CLR_NONE, the arrow is not shown on the chart.

__________________________________________________________________________________________________

But you suggest to make two operations:
1. open the opposite position with a smaller lot;

2. Close them counterclockwise, so that the position whose lot was bigger is left.

__________________________________________________________________________________________________

bool OrderCloseBy( int ticket, int opposite, color Color=CLR_NONE)

Closes one open position with another position opened on the same instrument, but in the opposite direction. Returns TRUE on successful completion of the function. Returns FALSE if the function fails. To get information about the error, call the GetLastError() function.
Parameters:
ticket - Unique serial number of the order to be closed.
opposite - The unique sequence number of the opposite order.
Color - Colour of the closing arrow on the chart. If this parameter is missing or its value is CLR_NONE, the arrow is not shown on the chart.

_________________________________________________________________________________________________

Accordingly, the number of adverse factors doubles per position.

Why?



Yes, you have written in exhaustive detail, but nevertheless I didn't see any difference.

Namely, sending a request to open a lot (my variant) or a command to close a part of a lot (your variant) are subject to the same risk of requotes and slippage.

And closing by OrderCloseBy() carries no risk, because requotes and slippage no longer matter, because after opening a lot (my variant), they de facto do not exist, i.e. mutually exclude each other.

Reason: