Saeed Al Junaibi: Is it possible to find the margin used per position in the history? I made my own expert to export trade history but I couldn't find any variable like (OrderMargin). I know how margin is calculated, it requires the currency price at the open time then it's: Margin = 100,000 * Lots * Open Price / (leverage) * (1 for buy and -1 for sell). However this doesn't return the same margin calculated in the platform. Does it include the spread difference when calculating open price? If so, there isn't even a variable for spread per trade (OrderSpread). What would be the best way to accurately calculate this?
You may be able to use OrderCalcMargin function with the data from the trade history to find out what margin was used. It should automatically account for the various ways that margin is calculated based on the SYMBOL_TRADE_CALC_MODE. However, it may not account for any exchange rate conversions at the time the trade was placed.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
Is it possible to find the margin used per position in the history? I made my own expert to export trade history but I couldn't find any variable like (OrderMargin).
I know how margin is calculated, it requires the currency price at the open time then it's: Margin = 100,000 * Lots * Open Price / (leverage) * (1 for buy and -1 for sell)
However this doesn't return the same margin calculated in the platform. Does it include the spread difference when calculating open price? If so, there isn't even a variable for spread per trade (OrderSpread).
What would be the best way to accurately calculate this?