EA Buying Order
To close a "buy" position, it needs to carry out a "sell" deal. That is normal.
Look at your trade history and you will see a "buy in deal" to open the position and a "sell out deal" to close the position.
A simple way to view it ...
- Order — the request (current and history)
- Deal — the action (history)
- Position — the result (current)
Read the following article ...
Orders, Positions and Deals in MetaTrader 5
MetaQuotes, 2011.02.01 16:13
Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
then closes that particular position.
After buying and closes the position the Journal shows an instant sell which I didn’t require.
Please find below the Journal display,
2023.09.01 19:55:33.012 Experts expert ordersB (AUDCAD,H1) loaded successfully
2023.09.01 19:55:33.136 Trades '5017229452': instant buy 0.1 AUDCAD at 0.87746
2023.09.01 19:55:33.172 Trades '5017229452': accepted instant buy 0.1 AUDCAD at 0.87746
2023.09.01 19:55:33.173 Trades '5017229452': deal #50653374494 buy 0.1 AUDCAD at 0.87746 done (based on order #50661441539)
2023.09.01 19:55:33.173 Trades '5017229452': order #50661441539 buy 0.1 / 0.1 AUDCAD at 0.87746 done in 37.266 ms
2023.09.01 19:55:33.174 Trades '5017229452': instant sell 0.1 AUDCAD at 0.87734, close #50661441539 buy 0.1 AUDCAD 0.87746 (deviation: 10)
2023.09.01 19:55:33.206 Trades '5017229452': accepted instant sell 0.1 AUDCAD at 0.87734, close #50661441539 buy 0.1 AUDCAD 0.87746 (deviation: 10)
2023.09.01 19:55:33.207 Trades '5017229452': deal #50653374497 sell 0.1 AUDCAD at 0.87734 done (based on order #50661441542)
2023.09.01 19:55:33.207 Trades '5017229452': order #50661441542 sell 0.1 / 0.1 AUDCAD at 0.87734 done in 33.780 ms
I will appreciate if somebody can help.