Margin/Spread per trade in trade history?

S J  

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?

Fernando Carreiro  
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.
Reason: