You cannot close an Order, you can delete a Pending Order. You can place an Order and once it is executed it becomes a deal, that deal may create, add to or subtract from a position.
If you take 2 containers each holding a gallon of water and empty them both into a 5 gallon container and mixed them well. Some time later how would you go about extracting just the water in one of the original gallons of water ?
There are no individual deals . . . you need to read the information at the link I gave and understand the consequences. This isn't mql4, there are no open orders except pending orders, a deal is a transitory thing, it transits the order to the position, you cannot close a deal. To close the equivalent of a position opened/added to with 0.34 lots close 0.34 lots of your open position.
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I hope this will be helpfull!
but if the software got restarted, all the data will be gone.
secondly the average price in the position will used instead of the deal open price.
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I hope this will be helpfull!
You are right, this is the only solution if you need to manage several trades.
I hope to bring this up again because some strategy I use need to close individual order instead of the whole position.
Can MQ give some info???
You cannot close an Order, you can delete a Pending Order. You can place an Order and once it is executed it becomes a deal, that deal may create, add to or subtract from a position.
If you are using and discussing MT5/mql5 you must use the correct terminology if you want to communicate effectively: Orders, Positions and Deals in MetaTrader 5
so sorry, its deal...
can close individual deals???
Create a new order, opposite direction of your deal, with same volume. (Please don't double posts).
but I just want to close the order in profit
any workaround??
but I just want to close the order in profit
any workaround??
so sorry, its deal...
can close individual deals???
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I hope this will be helpfull!
Yes, of course. The average entry price may be changed only with entry, not exit.
I think average price will change with both entry and exit.
1 lots @ 2
1 lots @ 3
1 lots @ 4
average price = (2+3+4)/3 = 3
close 1 lot.
considering if @ 2 FIFO based closed the average = (3+4)/2=3.5
considering if @ 3 LIFO based closed the average = (2+4)/2 = 3
considering if @ 4 is closed the average = (2+3)/2 = 2.5
Thats a lot of difference, a difference if ending in a profit/loss. I guess we all want to be in profit, so accuracy of calculation is very important.
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I hope this will be helpfull!
but if the software got restarted, all the data will be gone.
secondly the average price in the position will used instead of the deal open price.
I think I have a solution to it. If you are coding an expert advisor. Use an array to store the deal details as it is made one by one and close each deal as and when required using the same array information.
Instead of depending on the terminal to provide you the deal details, you can create a similar array table by yourself and track the price movements.
I hope this will be helpfull!
I think average price will change with both entry and exit.
1 lots @ 2
1 lots @ 3
1 lots @ 4
average price = (2+3+4)/3 = 3
close 1 lot.
considering if @ 2 FIFO based closed the average = (3+4)/2=3.5
considering if @ 3 LIFO based closed the average = (2+4)/2 = 3
considering if @ 4 is closed the average = (2+3)/2 = 2.5
Thats a lot of difference, a difference if ending in a profit/loss. I guess we all want to be in profit, so accuracy of calculation is very important.