How to calc corretly all the costs of a completed transaction?

 

I want to know how to calculate corretly all costs to open and close a position to be able to handle better an dynamic volume entrances. 


I search about this topic here, but It was very hard to find something useful. The relevant tools that I found were: 

To get margin from symbols: https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants

To get margin account: https://www.mql5.com/en/docs/constants/environment_state/accountinformation

To calculate a estimated profit: https://www.mql5.com/en/docs/trading/ordercalcprofit

To calculate the needed margin to open an order: https://www.mql5.com/en/docs/trading/ordercalcmargin


My questions are:

1. Is there some article or guide that shows how to open / close positions safety, looking by all possible costs involved? I found articles to check my account and environment, but none to check each operation.

2. Always OrderCalcProfit returns the same as PositionGetDouble (POSITION_PROFIT)? In my tests it's true, but I don't know if it's coincidence ...

3. Where can I found the broker fees and charges to add to the profit calculation?

4. There is some MQL5 article that explains how the tool handle stocks and the differences among other symbols (like forex, futures, etc.)? If it not exists, will be very helpful the indication of a good documentation to understand the peculiarities of the stocks trades to build a good EA.


Tks by advance

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5