An order volume, a deal volume and a position volume are 3 different things. You need to deal with that on a real account when opening a position greater than the minimum.
As an order of 4 for example can result in 1 deal (4 or even possibly 3 only) or 2 deals (1+3 or 2+2...), 3 deals...or 4 deals.
An order volume, a deal volume and a position volume are 3 different things. You need to deal with that on a real account when opening a position greater than the minimum.
As an order of 4 for example can result in 1 deal (4 or even possibly 3 only) or 2 deals (1+3 or 2+2...), 3 deals...or 4 deals.
Ok. So, from what I understand, the error is that I am using DEAL_VOLUME and instead I should look for the value of the volume of the executed order and not of the deal carried out, perhaps using HistoryOrderGetDouble.
Anyway, thanks for the help. It was enough to give me a path to fix.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
EA Places Orders BuyLimit and SellLimit on the chart to enter the operation and when one of these orders is executed it places a reverse order (BuyLimit or SellLimit) to exit the operation, functioning as a TakeProfit. When this exit order is executed, it replaces the entry order in the same place as before and with the same volume of contracts.
It turns out that I used the function OnTradeTransaction for this manipulation of orders and everything happens correctly on a DEMO account and on a REAL account with 1 volume contract.
The problem occurs when I try to use more than 1 volume contract on the REAL account. The EA executes an entry order with 4 contracts and sometimes places an exit order with only 3 contracts, or sometimes it places the exit with the correct number of contracts, but when it is executed the entry order is replaced. ends up having fewer contracts.
My suspicion is that there may be an error in the way I am using the enum DEAL_VOLUME, however I was unable to identify what the logic error would be.
Important points: 1- The bug always occurs with a smaller number of contracts, it never happened to add more contracts.
2- The bug does not occur on Demo accounts and on Strategy Tester s.
3- In the real account, sometimes the correct number of contracts is placed and sometimes the bug occurs.
4- If you use the EA for a long time, the bug will always occur, decreasing contracts until one hour remains just 1 contract.
Below is the OnTradeTransaction code (The rest of the EA code has no connection with this function)