Calculating Margin Used by Existing Position from Indicator's Code

 

Hello all!

How can one get or calculate the exact value of margin used by a particular position from the indicator's code? I know how to do that if the position is the only one, but when two or more positions are open, it seems like an impossible task.

Any ideas?

Reason: