Please study the example closely. The open price is unchanged, Its the average open price that is changing.
See the difference is average price considering that one of the deal is closed.
That makes no sense. There is only 1 position with an open price who is calculated by averaging price of deals with in direction. When you make a deal with out direction, P/L is calculated by the difference between the open price of the position and the price of the out deal. The volume of the position is reduced by the volume of this out deal and the open price doesn't change.
i open two deal at 100 and 50. Price now is at 75 and I decide to close the deal open at 50. My profit will be 0 right?
Seems you still don't understand what is a deal, you can said that a deal is open or close, that makes no sense. A deal has a direction, it can be in or out (or in/out but keep it simple). A deal with in direction add to your actual position, the open price of the position is then calculated by averaging price. A deal with out direction reduced your position and open price doesn't change.
In your example, your P/L depends of the direction of your position/deal. Do you have a buy or a sell position at 75 ? Do you have a new deal at 50 which is in or out direction ?
Position
Deal
Results
BUY at 75
DEAL at 50 = BUY (IN)
Position BUY at new averaged price. No P/L
BUY at 75
DEAL at 50 = SELL (OUT)
Position BUY at unchanged price. P/L=-25 * lot size
SELL at 75
DEAL at 50 = BUY (OUT)
Position SELL at unchanged price. P/L=+25 * lot size
Seems you still don't understand what is a deal, you can said that a deal is open or close, that makes no sense. A deal has a direction, it can be in or out (or in/out but keep it simple). A deal with in direction add to your actual position, the open price of the position is then calculated by averaging price. A deal with out direction reduced your position and open price doesn't change.
In your example, your P/L depends of the direction of your position/deal. Do you have a buy or a sell position at 75 ? Do you have a new deal at 50 which is in or out direction ?
Position
Deal
Results
BUY at 75
DEAL at 50 = BUY (IN)
Position BUY at new averaged price. No P/L
BUY at 75
DEAL at 50 = SELL (OUT)
Position BUY at unchanged price. P/L=-25 * lot size
SELL at 75
DEAL at 50 = BUY (OUT)
Position SELL at unchanged price. P/L=+25 * lot size
SELL at 75
DEAL at 50 = SELL (IN)
Position SELL at new averaged price. No P/L
Terms aside. Lets use layman terms.
In my given example. I buy at price 100 (1 lot) and at 50 (1 lot). My average open price would be 75 correct?
When the price is at 75 and I decided to close 1 lot. For the closed position of 1 lot, my profit would be 0 correct?
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.
AmitJamuda solution is the only way to do what you want in MT5/mql5, obvisouly it's not a trivial task and you have to manage persistance of the data.
Anyway what you want is to do the same as in MT4/mql4 with MT5/mql5. Why don't use MT4/mql4 then ? It's a lot more easy to do.
AmitJamuda solution is the only way to do what you want in MT5/mql5, obvisouly it's not a trivial task and you have to manage persistance of the data.
Anyway what you want is to do the same as in MT4/mql4 with MT5/mql5. Why don't use MT4/mql4 then ? It's a lot more easy to do.
No, you are wrong. Open price don't change when you "close" part of a position.
Please study the example closely. The open price is unchanged, Its the average open price that is changing.
See the difference is average price considering that one of the deal is closed.
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.
Please study the example closely. The open price is unchanged, Its the average open price that is changing.
See the difference is average price considering that one of the deal is closed.
opps. I meant average open price.
for example
i open two deal at 100 and 50. Price now is at 75 and I decide to close the deal open at 50. My profit will be 0 right?
Please study the example closely. The open price is unchanged, Its the average open price that is changing.
See the difference is average price considering that one of the deal is closed.
opps. I meant average open price.
for example
i open two deal at 100 and 50. Price now is at 75 and I decide to close the deal open at 50. My profit will be 0 right?
Seems you still don't understand what is a deal, you can said that a deal is open or close, that makes no sense. A deal has a direction, it can be in or out (or in/out but keep it simple). A deal with in direction add to your actual position, the open price of the position is then calculated by averaging price. A deal with out direction reduced your position and open price doesn't change.
In your example, your P/L depends of the direction of your position/deal. Do you have a buy or a sell position at 75 ? Do you have a new deal at 50 which is in or out direction ?
Seems you still don't understand what is a deal, you can said that a deal is open or close, that makes no sense. A deal has a direction, it can be in or out (or in/out but keep it simple). A deal with in direction add to your actual position, the open price of the position is then calculated by averaging price. A deal with out direction reduced your position and open price doesn't change.
In your example, your P/L depends of the direction of your position/deal. Do you have a buy or a sell position at 75 ? Do you have a new deal at 50 which is in or out direction ?
Terms aside. Lets use layman terms.
In my given example. I buy at price 100 (1 lot) and at 50 (1 lot). My average open price would be 75 correct?
When the price is at 75 and I decided to close 1 lot. For the closed position of 1 lot, my profit would be 0 correct?
Terms aside. Lets use layman terms.
If you do not use the correct terms you cannot communicate effectively . . .
Orders, Positions and Deals in MetaTrader 5